import { Component, OnInit } from '@angular/core';
import { FadeInTop } from "../../shared/animations/fade-in-top.decorator";
import { JsonApiService } from "app/core/api/json-api.service";
import { NotificationService } from "../../shared/utils/notification.service";
import { config } from '../../shared/smartadmin.config';
import { Router, ActivatedRoute } from "@angular/router"; //路由引入

declare var $: any;
declare var BMap: any;
declare var echarts: any;
declare var toMapPoint: any;
declare var toMapPointArr: any;
declare var toWGS84: any;
declare var INFOBOX_AT_TOP;
@FadeInTop()
@Component({
	selector: 'sa-path-fix3',
	templateUrl: './path-fix3.component.html',
	styleUrls: ['./path-fix3.css', './timeline.css']
})

export class PathFix3Component implements OnInit {
	constructor(private jsonApiService: JsonApiService, private notificationService: NotificationService, private router: Router, private activatedRoute: ActivatedRoute) {
		activatedRoute.queryParams.subscribe(queryParams => {
			if (queryParams) {
				this.jumpData = queryParams;
				// 订单监控跳转过来的数据
				if (common.getCookie('pathFixFromOrderManagenment')) {
					this.jumpData = JSON.parse(common.getCookie('pathFixFromOrderManagenment'));
					common.clearCookie('pathFixFromOrderManagenment');
					this.initDateRange.startTime = this.jumpData.emptyLoadTime;
					this.initDateRange.endTime = this.jumpData.unloadEndTime ? this.jumpData.unloadEndTime : this.jumpData.lastDeviceTime;
					this.deviceId = this.jumpData.deviceId;
					this.companyId = this.selectedCompanyId = this.jumpData.companyId;
					this.orderId = this.jumpData.id; //订单ID
					this.orderCode = this.jumpData.orderCode;
					this.orderDeviceId = this.jumpData.deviceId;
					this.companyCarNumberValue = {
						companyId: this.jumpData.companyId,
						companyName: this.jumpData.companyName,
						carNumber: this.jumpData.carNumber,
						deviceId: this.jumpData.deviceId,
					}
				}
			}
		});
	}
	orderId: any = '';//跳转携带 
	orderCode: any = ''; //跳转携带
	orderDeviceId: any = '' // 携带过来的车牌号码
	companyCarNumberValue: any = {}// 公司车辆组件渲染的数据
	initDateRange: any = {}// 时间组件需要渲染的值
	drawActive: string;//当前绘图激活模块

	alertChartModelInfo: any = {};//echart异常警报信息模板信息
	versionChartModuleInfo: any = {};//echart固件升级信息模板信息
	coefChartModuleInfo: any = {};//echart系数设置信息模板信息
	jumpData: any;
	isAllowPre: boolean = false;
	isAllowNext: boolean = false;
	isButtonDis: boolean = false;

	myMap: any;
	apiType = '1'; //api接口
	lookSignal = true; //是否查看信号的条件
	loadometer = false; //是否查地磅信息的条件
	linetoMap = true; //是否选择地图联动的条件
	carSpeed = true; //是否查看速度的条件
	showModify = true; //显示修正数据
	questionRecord = true; //问题记录
	versionNumber = true;//版本号
	sensorChannel: boolean = false;//记录损坏传感器开关
	voltage: boolean = false;//设备电压信息开关
	deviceStatus: boolean = true;//设备状态开关
	versionMessage = {
		name: '',
		versionString: '',
		runStatus: '',
		carUploadDate: '',
		gpsUploadDate: '',
		isShowGPS: false,
	};//版本信息
	isGetRecord: any = { status: false };   //子组件是否请求问题记录数据

	routePlanningPolyline: any


	filterTime = '';
	filterTimeDefault: number;
	multiple = 1;
	magnificationArr = [1000, 5000, 10000, 100000]; //重量放大倍数
	startTime = '';
	endTime = '';
	startProblemTime = '';
	endProblemTime = '';
	problemStartTime = "";
	problemEndTime = "";
	companyId = '';
	selectedCompanyName = '';
	selectedCompanyId = '';


	inpSelect = ''; //点击折线获取时间 选中的输入框
	zeroBeforeDate = '';
	upStartDate = '';
	upEndDate = ''
	downStartDate = '';
	downEndDate = '';
	zeroAfterDate = '';

	carNumber = '';
	carList = [];
	companyList = [];
	companyNameArr = [];
	companyName = '';
	deviceId = ''; //设备ID
	startDate = ''; //开始时间
	endDate = ''; //结束时间
	waveWeight = '1.0';//波动范围

	myChart: any;
	allData = []; //echart图后台请求回来的数据
	passageData = []; //所有chart图折线的数组
	linetoMapData = []; //地图联动画轨迹数据
	loadometerData = []; //后台返回的地磅数据
	loadometerArr = []; //拼接成echart数组
	weightArr = []; //重量折线的数据
	carSpeedArr = []; //速度折线的数据
	passageName = []; //ad信号折线名
	passageArr = []; //ad信号数据
	voltageData: any = [];//设备电压数据,echart显示电压曲线
	voltageDataEchart: any = [];//设备电压数据,处理后数据

	errorRateArr = []; //记录误差率
	errorValueArr = []; //记录误差值       
	poundWeight = 0;//当前地磅重量
	errorRate: any = 0;//当前误差率
	errorValue = 0;//当前误差值
	signal16Arr = [];//16通道的数据
	ad16Value = 0;//对应地磅数据的16通道的信号误差值
	ad16Rate: any = 0;//对应地磅数据的16通道的信号值的误差率
	isRate16 = false;//是否计算16通道的误差率

	moveCanvasLayer: any; //轨迹移动添加点图层
	carMoveCanvasLayer: any;//移动折线对应地图添加点的图层,

	abnormalInfo;//地图上的异常警报窗口

	sensorTableData: any = [];//传感器损坏模块table数据
	startTime_sensor: string = '';//损坏传感器开始时间
	endTime_sensor: string = '';//损坏传感器结束时间
	sensorList: any = []; // 设备事件模块中的传感器通道问题数组
	otherData: any = {}; // 设备事件模块中的其他数据 弥补之前的接口数据不足
	sensorArr: any = [{
		id: 1,
		text: '通道1',
		checked: false
	}, {
		id: 2,
		text: '通道2',
		checked: false
	}, {
		id: 3,
		text: '通道3',
		checked: false
	}, {
		id: 4,
		text: '通道4',
		checked: false
	}, {
		id: 5,
		text: '通道5',
		checked: false
	}, {
		id: 6,
		text: '通道6',
		checked: false
	}, {
		id: 7,
		text: '通道7',
		checked: false
	}, {
		id: 8,
		text: '通道8',
		checked: false
	}, {
		id: 9,
		text: '通道9',
		checked: false
	}, {
		id: 10,
		text: '通道10',
		checked: false
	}, {
		id: 11,
		text: '通道11',
		checked: false
	}, {
		id: 12,
		text: '通道12',
		checked: false
	}, {
		id: 13,
		text: '通道13',
		checked: false
	}, {
		id: 14,
		text: '通道14',
		checked: false
	}, {
		id: 15,
		text: '通道15',
		checked: false
	}, {
		id: 16,
		text: '通道16',
		checked: false
	}]
	private isMoveFlag: boolean = true;		//防抖节流，控制mousemove触发频率
	//	powerOffAlertList:any = [];//断电异常数据集合

	//重量y轴线
	yAxiWeight: any = {
		show: true,
		name: '重量',
		type: 'value',
		position: 'left',
		min: undefined,
		max: undefined,
		offset: undefined,
		axisLine: {
			lineStyle: {
				color: 'gray'
			}
		},
		axisLabel: {
			formatter: '{value}'
		}
	}

	//信号y轴线
	yAxiSignal: any = {
		show: false,
		name: '信号',
		splitLine: {
			show: false
		},
		type: 'value',
		position: 'right',
		min: undefined,
		max: undefined,
		offset: undefined,
		axisLine: {
			lineStyle: {
				color: '#5c427c'
			}
		},
		axisLabel: {
			formatter: '{value}'
		}
	}

	//速度y轴线
	yAxiSpeed: any = {
		show: false,
		name: '速度 KM/H',
		splitLine: {
			show: false
		},
		type: 'value',
		min: undefined,
		max: undefined,
		offset: 60,
		position: 'right',
		axisLine: {
			lineStyle: {
				color: '#5793f3'
			}
		},
		axisLabel: {
			formatter: '{value}'
		}
	}

	//	指定图表的配置项和数据
	echartOption = {
		tooltip: {
			trigger: 'axis',
			axisPointer: {
				type: 'cross' //十字星	
			},
			formatter: function (params) {
				if (this.linetoMap) {
					var paramIndex = params[0].dataIndex;
					var pointObj = this.linetoMapData[paramIndex];
					if (!pointObj || pointObj.x == '' || pointObj.x == '0') {
						return;
					}
					this.lineMoveCarPoint(pointObj)
				}

				if (!window.event) {
					return;
				}
				if (!window.event.type) {
					return;
				}
				var triggerType = window.event.type; //触发类型
				if (triggerType == 'click') {
					let pointObj = this.allData[params[0].dataIndex];
					let pointString = pointObj.x + "," + pointObj.y;
					if (this.inpSelect) {
						this.htmlParams[this.inpSelect] = params[0].name;
						switch (this.inpSelect) {
							case 'runBefore':
								this.focusInpType = 'starPoint';
								this.planningMarkerAdd(pointObj.lng, pointObj.lat);
								this.planningMarker.starPoint.val = pointString;
								break;
							case 'stopBefore':
								this.focusInpType = 'endPoint';
								this.planningMarkerAdd(pointObj.lng, pointObj.lat);
								this.planningMarker.endPoint.val = pointString;
								break;
							default:
								break;
						}
					}
					if (this.focusInpType && !this.inpSelect && pointObj) {
						this.planningMarkerAdd(pointObj.lng, pointObj.lat);
						if (this.focusInpType == 'starPoint') {
							this.planningMarker.starPoint.val = pointString;
						}
						else if (this.focusInpType == 'endPoint') {
							this.planningMarker.endPoint.val = pointString;
						}
					}
				}
			}.bind(this)
		},
		grid: {
			left: '54px',
			right: '100px',
			top: '100px'
		},
		toolbox: {
			feature: {
				dataView: {
					show: false,
					readOnly: false
				},
				restore: {
					show: false
				},
				saveAsImage: {
					show: false
				}
			}
		},
		legend: {
			selected: {},
		},
		xAxis: {
			type: 'category',
			boundaryGap: false,
			data: []
		},
		yAxis: [this.yAxiWeight],

		dataZoom: [{

			realtime: true
		}, {
			type: 'inside',
			realtime: true,
		}],
		series: [{
			name: '重量',
			type: 'line',
			//			itemStyle: {
			//				color: 'red'
			//			},
			data: []
		}]

	};

	isDisable = true;
	coefCarStatus = 'offline';
	coefCarNumber = '';

	proTypeOptions = [];//存储问题记录分类选项描述
	proSlectedItem: any;//记录选中一类时的数据,渲染页面选项
	proTypeParams: any = {		//存储用户操作选择的数据
		problemType: '',			//问题类型
		problemClass: '',		//问题分类
		phenomenon: '',			//问题现象
		repairGuide: '',			//维修指导
		repairWay: '',			//维修方式
		pheDescribe: '',			//现象描述
	}
	seneorPhenlist = [];

	hideOrshowline = [];
	legendSleced: any = {};
	carIndexMess = {
		allNums: 0,
		index: 1,
		status: false,
	}

	message(data) {
		this.notificationService.smallBox({
			content: data,
			timeout: 3000
		});
	}
	confirm_message(message) {
		return new Promise(function (resolve, reject) {
			this.notificationService.smartMessageBox({
				title: "提示",
				content: message,
				buttons: '[确认][取消]'
			}, (ButtonPressed) => {
				if (ButtonPressed === "确认") {
					resolve();
				}
				if (ButtonPressed === "取消") {
					this.notificationService.smallBox({
						content: "操作取消",
						timeout: 3000
					});
					return;
				}

			});
		}.bind(this))
	}
	//公司选中回调
	companySelected(val) {
		console.log(this.deviceId, '======deviceId=======')
		this.deviceId = val.deviceId;
		this.carNumber = val.carNumber;
		this.selectedCompanyId = val.companyId;
		this.selectedCompanyName = val.companyName;
	}
	//获取传感器参数
	getVersionMessage(activeDeviceId) {
		this.versionMessage = {
			name: '',
			versionString: '',
			runStatus: '',
			carUploadDate: '',
			gpsUploadDate: '',
			isShowGPS: false,
		}
		let reqdata = 'deviceId=' + activeDeviceId;
		this.hideOrshowline = [];
		this.jsonApiService.http("system/getRealTimeData.html", reqdata).subscribe(result => {
			if (!result.success) return;
			this.versionMessage.name = result.data.version;
			this.versionMessage.runStatus = result.data.runStatus;
			this.versionMessage.carUploadDate = result.data.carUploadDate;
			this.versionMessage.gpsUploadDate = result.data.gpsUploadDate;
			let abs = Math.abs(common.mmsstoTimestamp(this.versionMessage.carUploadDate) - common.mmsstoTimestamp(this.versionMessage.gpsUploadDate));
			abs >= 30 * 60 * 1000 ? this.versionMessage.isShowGPS = true : this.versionMessage.isShowGPS = false;
			let coefArr = [];
			if (!result.data.coef) return
			for (let i = 0; i < result.data.coef.length; i++) {
				let item = result.data.coef[i];
				if (item) {
					let vname = '通道' + (i + 1);
					coefArr.push(vname + ':' + item);
					this.hideOrshowline.push(vname)
				}
			}
			let resultString = '';
			for (let _i = 0; _i < coefArr.length; _i++) {
				if (_i < coefArr.length - 1) {
					resultString += coefArr[_i] + ',';
				} else {
					resultString += coefArr[_i]
				}
			}
			this.versionMessage.versionString = resultString;
		})
	}
	ngOnInit() {
		System.import('script-loader!select2/dist/js/select2.min.js').then(() => {
			System.import('assets/js/select2-zh-CN.js').then(() => {
				this.initReplaceCarNumberSelect2();
			});
		});
		this.initDate();
		// 榜单数据
		let that = this;
		this.myChart = echarts.init(document.getElementById('chart'));
		this.initChart();
		window.onresize = function () {
			setTimeout(() => {
				that.myChart.resize()
			}, 120)
		}
		let map = new BMap.Map('baiduMap', { enableMapClick: false }); //创建地图实例
		let point = new BMap.Point(116.404, 39.915); //创建点坐标
		map.centerAndZoom(point, 12); //初始化地图，设置中心点坐标和地图级别
		// var geolocation = new BMap.Geolocation();
		// geolocation.getCurrentPosition(function(r){
		//     if(this.getStatus() == 0){
		//         var mk = new BMap.Marker(r.point);
		//         map.panTo(r.point);
		//     }      
		// },{enableHighAccuracy: true})
		map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
		map.disableDoubleClickZoom();//禁用双击放大
		this.myMap = map;
		this.getPointEvent();
		this.initBmapAutoSearch();
		this.calcMapHeight();
		if (this.jumpData.deviceId) {
			setTimeout(() => {
				that.showCheart();
			}, 100)
		}
	}
	calcMapHeight() {
		let navHeight;
		let timer = setTimeout(() => {
			navHeight = $("#left-panel").height() + 100
			let mapTop = $("#baiduMap").offset().top;
			let height = navHeight - mapTop;
			$("#baiduMap").height(height)
			clearTimeout(timer)
			timer = null
		}, 0);
	}
	baiPoint: any = '';
	// 百度地图自动检索功能
	initBmapAutoSearch() {
		//建立一个自动完成的对象
		var map = this.myMap;
		let autoSearch = new BMap.Autocomplete({ "input": "suggestId", "location": this.myMap });
		autoSearch.addEventListener("onhighlight", function (e) {  //鼠标放在下拉列表上的事件
			var str = "";
			var _value = e.fromitem.value;
			var value = "";
			if (e.fromitem.index > -1) {
				value = _value.province + _value.city + _value.district + _value.street + _value.business;
			}
			str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

			value = "";
			if (e.toitem.index > -1) {
				_value = e.toitem.value;
				value = _value.province + _value.city + _value.district + _value.street + _value.business;
			}
			str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
			document.getElementById("searchResultPanel").innerHTML = str;
		});
		let myValue;
		autoSearch.addEventListener("onconfirm", function (e) {    //鼠标点击下拉列表后的事件
			let _value = e.item.value;
			myValue = _value.province + _value.city + _value.district + _value.street + _value.business;
			document.getElementById("searchResultPanel").innerHTML = "onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
			let local = new BMap.LocalSearch(this.myMap, { //智能搜索
				onSearchComplete: function (result) {
					var pp = result.getPoi(0).point;    //获取第一个智能搜索的结果
					this.baiPoint = pp;
					this.myMap.centerAndZoom(pp, 18);
					map.addOverlay(new BMap.Marker(pp));
				}.bind(this)
			});
			local.search(myValue);


		}.bind(this));
	}
	ngOnDestroy() {
		document.onclick = null;
		document.onkeydown = null;
		document.body.onkeydown = null;
		window.onresize = null;
		$(document).unbind('keyup'); //移除键盘回车事件
	}
	//初始化echart图
	initChart() {
		this.allData = []; //echart图后台请求回来的数据
		this.passageData = []; //所有chart图折线的数组
		this.linetoMapData = []; //地图联动画轨迹数据
		this.loadometerData = []; //后台返回的地磅数据
		this.loadometerArr = []; //拼接成echart数组
		this.weightArr = []; //重量折线的数据
		this.carSpeedArr = [];//速度折线的数据
		this.passageName = [];//ad信号折线名
		this.passageArr = [];//ad信号数据
		this.echartOption.xAxis.data = [];
		this.echartOption.series = [];
		this.myChart.setOption(this.echartOption, true);
	}

	//百度地图绘画路线,不带方向箭头,当前版本不用该函数
	//	drawTrack(map, param) {
	//		var pointArr = param;
	//		map.clearOverlays();
	//	
	//		var linkPoint = [];
	//		var linkPoint = []; //拼接线的折点
	//	
	//		for(var i = 0; i < pointArr.length; i++) {
	//			//    转换成百度坐标
	//			var mapPoint = toMapPoint(pointArr[i]);
	//			if(mapPoint) {
	//				linkPoint.push(new BMap.Point(mapPoint.lng, mapPoint.lat));
	//			}
	//		}
	//		var polyline = new BMap.Polyline(linkPoint, {
	//			strokeColor: "#4169e1",
	//			strokeWeight: 6,
	//			strokeOpacity: 0.9
	//		}); //创建折线
	//		map.addOverlay(polyline);
	//		var starPoint = new BMap.Point(pointArr[0].lng, pointArr[0].lat);
	//		var endPoint = new BMap.Point(pointArr[pointArr.length - 1].lng, pointArr[pointArr.length - 1].lat);
	//		var opts = {
	//			position: starPoint, // 指定起点所在的地理位置
	//			offset: new BMap.Size(0, 0) //文本偏移量
	//		};
	//		var endOpts = {
	//			position: endPoint, // 指定终点点所在的地理位置
	//			offset: new BMap.Size(0, 0) //文本偏移量
	//		};
	//		var label = new BMap.Label('起点', opts); // 创建文本内容
	//		var endLabel = new BMap.Label('终点', endOpts); // 创建文本内容
	//		label.setStyle({
	//			color: "red",
	//			fontSize: "12px",
	//			height: "20px",
	//			padding: "0px 30px 0 2px",
	//			margin: 0,
	//			lineHeight: "20px",
	//			fontFamily: "微软雅黑"
	//		});
	//		endLabel.setStyle({
	//			color: "red",
	//			fontSize: "12px",
	//			height: "20px",
	//			padding: "0px 30px 0 2px",
	//			margin: 0,
	//			lineHeight: "20px",
	//			fontFamily: "微软雅黑"
	//		});
	//		map.addOverlay(label);
	//		map.addOverlay(endLabel);
	//		setTimeout(function() {
	//			map.centerAndZoom(new BMap.Point(pointArr[pointArr.length - 1].lng, pointArr[pointArr.length - 1].lat), 10);
	//		}, 10);
	//	}
	//定义转换时间戳函数
	changeTime(str) {
		let str1 = str.replace(/-/g, "/");
		let timestamp = new Date(str1).getTime();
		return timestamp;
	}
	mapClick: boolean = true;	//地图点击防抖节流
	clickCount: number = 0;  //计算点击绘图的次数
	//生成echart折线图
	showCheart() {
		this.clickCount += 1;
		if (this.clickCount > 1) {
			this.jumpData = null;
		}
		if (!this.deviceId) {
			this.message('请选择需要查看的车辆');
			return;
		}
		if (!this.startTime) {
			this.message('开始时间不能为空');
			return;
		}
		if (!this.endTime) {
			this.message('结束时间不能为空');
			return;
		}
		$('.warpBox')[0].style.border = "1px solid #cccccc"; //改变时间区间框的颜色
		this.drawActive = '1';
		let timeCheck = common.correctTimeParams(this.startTime, this.endTime, 0);
		if (!timeCheck.status) {
			this.jsonApiService.message(timeCheck.message);
			return;
		}
		this.myMap.clearOverlays();
		function nullUpdate() { }
		this.carMoveCanvasLayer = new CanvasLayer({
			map: this.myMap,
			update: nullUpdate,
			zIndex: 10
		});
		this.moveCanvasLayer = new CanvasLayer({
			map: this.myMap,
			update: nullUpdate,
			zIndex: 10
		});
		this.myMap.addOverlay(this.carMoveCanvasLayer);
		this.myMap.addOverlay(this.moveCanvasLayer);
		this.askforData();
	}

	//创建生成异常警报弹窗
	createAbnormalInfo(infoData) {
		infoData.onTime = infoData.onTime ? infoData.onTime : '无';
		if (this.abnormalInfo) {
			this.myMap.removeOverlay(this.abnormalInfo);
		}
		let point = new BMap.Point(infoData.lng, infoData.lat);
		infoData.abType = infoData.type == '1' ? '主板开关机事件' : '主机上下电事件';
		let lostWeightHtml = '';
		if (infoData.lostime) {
			lostWeightHtml = '<li><span class="leftSpan">重量丢失：</span><span class="rightSpan"> 约' + this.convertTime(infoData.lostime) + '</span></li>';
		}
		let html = '<div class="abInfobox infoBox">' +
			'<div class="title">' + infoData.carNumber + '异常信息</div>' +
			'<div class="content">' +
			'<ul>' +
			'<li><span class="leftSpan">异常类型：</span><span class="rightSpan"> ' + infoData.name + '</span></li>' +
			'<li><span class="leftSpan">开始时间：</span><span class="rightSpan"> ' + infoData.offTime + '</span></li>' +
			'<li><span class="leftSpan">结束时间：</span><span class="rightSpan"> ' + infoData.onTime + '</span></li>' +
			'<li><span class="leftSpan">异常时长：</span><span class="rightSpan"> ' + infoData.rangeTime + '</span></li>' +
			'<li><span class="leftSpan">发生地址：</span><span class="rightSpan"> ' + infoData.address + '</span></li>' +
			'</ul>' +
			'</div>' +
			'<div class="abpointer"></div>' +
			'</div>';
		this.abnormalInfo = new BMapLib.InfoBox(this.myMap, html, {
			boxStyle: {
				width: "240px",
				height: "0"
			},
			offset: new BMap.Size(240, 160),
			closeIconMargin: "12px 0px 0;z-index: 1;width: 18px",
			closeIconUrl: "assets/img/trackImage/close1.png",
			enableAutoPan: true,
			align: INFOBOX_AT_TOP
		});
		let marker = new BMap.Marker(point);
		this.abnormalInfo.open(marker);
	}
	timeShadow: any = []; 没有历史数据区域
	//后台获取数据
	askforData() {
		let activeStartTime, activeEndTime, activeDeviceId;
		if (this.drawActive == '1') {
			activeStartTime = this.startTime;
			activeEndTime = this.endTime;
			activeDeviceId = this.deviceId;
		} else if (this.drawActive == '2') {
			activeStartTime = this.htmlParams.replaceStartTime;
			activeEndTime = this.htmlParams.replaceEndTime;
			activeDeviceId = this.htmlParams.replaceDeviceId;
		} else {
			this.jsonApiService.message('请选择时间范围')
			return;
		}
		this.loadometerData = [];
		this.loadometerArr = [];
		this.voltageData = [];
		let _reqdata = 'deviceId=' + activeDeviceId + '&startTime=' + activeStartTime + '&endTime=' + activeEndTime + '&showModify=' + this.showModify;
		this.jsonApiService.http2("weighbridge/weightforreal.html", _reqdata).subscribe(result => {
			if (result.data.length >= 1) {
				this.loadometerData = result.data;
			}
		})
		this.jsonApiService.http2("logForVoltage/queryLogForVoltageByParam.html", _reqdata).subscribe(result => {
			if (result.data.length >= 1) {
				this.voltageData = result.data;
			}
		})
		this.initChart();
		layer.load();
		let reqdata = 'deviceId=' + activeDeviceId + '&startTime=' + activeStartTime + '&endTime=' + activeEndTime + '&showModify=' + this.showModify;
		let getDateUrl = "stats/draw.html"
		if (this.apiType == "2") {
			getDateUrl = "system/gpsweightAPI.html";
		}
		this.jsonApiService.http2(getDateUrl, reqdata).subscribe(data => {
			layer.closeAll('loading');
			this.getVersionMessage(activeDeviceId);
			this.allData = data.data;
			let temData = JSON.parse(JSON.stringify(data.data));
			this.drawTrackDatas = toMapPointArr(temData);
			//			.filter((data)=>{return data.speed > 3});// 速度小于3的数据过滤掉
			if (this.allData.length < 2) {
				this.message('没有数据')
				return;
			}
			this.linetoMapData = []; //地图联动轨迹画线数据
			this.carSpeedArr = [];//画速度折线数据
			let timeValue = [];
			let len = this.allData.length;
			var lostWeight = [];//记录重量丢失的时间
			var lostWeightMark = []; //计算丢失重量的时长
			let nullGpsArr = []; //经纬度为空或者0.0的画折线数据
			var nullMarkerData = []; //计算经纬度丢失的时长
			let isLostGps = false; //是否有丢失经纬度
			var isHavePoint = 0; //控制判断经纬度丢失起始结束位置计算时间条件
			/**
			 * 计算采样周期,用于判断重量丢失的阈值
			 * 取10组历史数据,取中位数作为数据采样的频率
			 */
			let temFilterArr: any = [];
			this.filterTimeDefault = 0;
			if (len > 10) {
				for (let i = 0; i < 10; i++) {
					let time1 = this.changeTime(this.allData[i].uploadDate);
					let time2 = this.changeTime(this.allData[i + 1].uploadDate);
					let diffTime = (time2 - time1) / 1000;
					temFilterArr.push(diffTime)
				}
				temFilterArr.sort(function (a, b) {
					return a - b;
				})
				this.filterTimeDefault = Number(temFilterArr[6]) * 1.5;
			}
			if (this.filterTime) {
				this.filterTimeDefault = Number(this.filterTime) > this.filterTimeDefault ? Number(this.filterTime) : this.filterTimeDefault;
			}
			this.filterTimeDefault = this.filterTimeDefault > 150 ? this.filterTimeDefault : 150;

			/**
			 * 对筛选时间范围内,返回的历史数据做处理,对于数据缺失的时间段进行数据的补点,在echart对应显示灰色区域,表明该时间段范围内没有历史数据. 
			 */
			this.timeShadow = [];
			if (common.mmsstoTimestamp(this.allData[0].uploadDate) - common.mmsstoTimestamp(activeStartTime) > this.filterTimeDefault * 1000) {
				// 判断曲线数据前有没有过磅数据,有过磅数据,显示无数据区域,没有过磅数据则不显示无数据区域
				let hasWeightInEmptyDataStartTime: boolean = false;
				for (let i = 0; i < this.loadometerData.length; i++) {
					let item = this.loadometerData[i];
					if (common.mmsstoTimestamp(activeStartTime) < common.mmsstoTimestamp(item.date) && common.mmsstoTimestamp(item.date) < common.mmsstoTimestamp(this.allData[0].uploadDate)) {
						hasWeightInEmptyDataStartTime = true;
						break;
					}
				}
				if (hasWeightInEmptyDataStartTime) {
					let emptyDataStartTime = [];//存放搜索开始时间空数据补点的集合
					for (let t = common.mmsstoTimestamp(activeStartTime); t < common.mmsstoTimestamp(this.allData[0].uploadDate); t = t + this.filterTimeDefault * 1000) {
						let temDate = common.getTimeMmss(new Date(t));
						let temObj = {
							aCH1: "",
							aCH2: "",
							aCH3: "",
							aCH4: "",
							aCH5: "",
							aCH6: "",
							aCH7: "",
							aCH8: "",
							aCH9: "",
							aCH10: "",
							aCH11: "",
							aCH12: "",
							aCH13: "",
							aCH14: "",
							aCH15: "",
							aCH16: "",
							checkGps: '',
							checkWeight: '',
							deviceId: activeDeviceId,
							handBrakeHardwareStatus: "",
							handBrakeSoftwareStatus: "",
							mWeight: "",
							rectifyWeight: "",
							rectifyX: "",
							rectifyY: "",
							speed: "",
							uploadDate: temDate,
							weight: "",
							x: this.allData[0].x,
							y: this.allData[0].y,
						}
						emptyDataStartTime.push(temObj);
					}

					let emptyShadowStart = [{
						name: "无数据",
						xAxis: activeStartTime
					}, {
						xAxis: this.allData[0].uploadDate
					}]
					this.timeShadow.push(emptyShadowStart);
					this.allData = emptyDataStartTime.concat(this.allData);
				}
			}
			if (common.mmsstoTimestamp(activeEndTime) - common.mmsstoTimestamp(this.allData[this.allData.length - 1].uploadDate) > this.filterTimeDefault * 1000) {
				// 判断曲线数据后有没有过磅数据,有过磅数据,显示无数据区域,没有过磅数据则不显示无数据区域
				let hasWeightInEmptyDataEndTime: boolean = false;
				for (let i = 0; i < this.loadometerData.length; i++) {
					let item = this.loadometerData[i];
					if (common.mmsstoTimestamp(this.allData[this.allData.length - 1].uploadDate) < common.mmsstoTimestamp(item.date) && common.mmsstoTimestamp(item.date) < common.mmsstoTimestamp(activeEndTime)) {
						hasWeightInEmptyDataEndTime = true;
						break;
					}
				}
				if (hasWeightInEmptyDataEndTime) {
					let emptyDataEndTime = [];//存放搜索结束时间空数据补点的集合
					let EndTime: string;
					if (new Date().getTime() - common.mmsstoTimestamp(activeEndTime) > 0) {
						EndTime = activeEndTime;
					} else {
						EndTime = common.getNowTime();
					}
					for (let t = common.mmsstoTimestamp(this.allData[this.allData.length - 1].uploadDate) + this.filterTimeDefault * 1000; t <= common.mmsstoTimestamp(EndTime); t = t + this.filterTimeDefault * 1000) {
						let temDate = common.getTimeMmss(new Date(t));
						let temObj = {
							aCH1: "",
							aCH2: "",
							aCH3: "",
							aCH4: "",
							aCH5: "",
							aCH6: "",
							aCH7: "",
							aCH8: "",
							aCH9: "",
							aCH10: "",
							aCH11: "",
							aCH12: "",
							aCH13: "",
							aCH14: "",
							aCH15: "",
							aCH16: "",
							checkGps: '',
							checkWeight: '',
							deviceId: activeDeviceId,
							handBrakeHardwareStatus: "",
							handBrakeSoftwareStatus: "",
							mWeight: "",
							rectifyWeight: "",
							rectifyX: "",
							rectifyY: "",
							speed: "",
							uploadDate: temDate,
							weight: "",
							x: this.allData[this.allData.length - 1].x,
							y: this.allData[this.allData.length - 1].y,
						}
						emptyDataEndTime.push(temObj);
					}
					let emptyShadowEnd = [{
						name: "无数据",
						xAxis: this.allData[this.allData.length - 1].uploadDate
					}, {
						xAxis: emptyDataEndTime[emptyDataEndTime.length - 1].uploadDate
					}]
					this.timeShadow.push(emptyShadowEnd);
					this.allData = this.allData.concat(emptyDataEndTime);
				}
			}
			len = this.allData.length;
			for (var i = 0; i < len; i++) {
				timeValue[i] = this.allData[i].uploadDate; //x时间轴数据
				if (!this.allData[i].weight) {
					this.allData[i].weight = '-';
				}
				this.weightArr[i] = this.allData[i].weight; //重量 
				if (this.weightArr[i] < 0 && this.weightArr[i] >= -1) {
					this.weightArr[i] = 0;
				}
				let _speed = parseFloat(this.allData[i].speed); //速度
				if (_speed > -1) {
					this.carSpeedArr[i] = parseFloat(this.allData[i].speed);
				} else {
					this.carSpeedArr[i] = 0;
				}
				this.loadometerArr[i] = '-';
				nullGpsArr[i] = '-';
				//计算经纬度等于0.0或者丢失的时候是时长start
				if (!this.allData[i] || !this.allData[i].x || this.allData[i].x == '0.0') {
					if (isHavePoint < 1) {
						isHavePoint = i;
					}
				} else {
					if (isHavePoint > 0) {
						var lostTime = (this.changeTime(this.allData[i].uploadDate) - this.changeTime(this.allData[isHavePoint].uploadDate)) / 1000;
						if (lostTime > this.filterTimeDefault) {
							var point = {
								value: this.convertTime(lostTime),
								xAxis: isHavePoint,
								yAxis: this.allData[isHavePoint].weight,
								lostime: lostTime,
							};
							nullMarkerData.push(point);
						}
						isHavePoint = 0
					}
				}
				//计算end
				if (i < len - 2) {
					//获取丢失的数据
					let lostStartime = this.changeTime(this.allData[i].uploadDate);
					let lostEndtime = this.changeTime(this.allData[i + 1].uploadDate);
					let lostime = (lostEndtime - lostStartime) / 1000;
					if (lostime > this.filterTimeDefault) {//重量时间段丢失
						var point = {
							value: this.convertTime(lostime),
							xAxis: i,
							yAxis: this.allData[i].weight,
							lostime: lostime,
						};
						lostWeightMark.push(point);
					}
					if (!this.allData[i].x || this.allData[i].x == '0.0') {
						//经纬度坐标丢失
						if (i > 0) {
							isLostGps = true;
							nullGpsArr[i] = this.allData[i].weight;
						}
					}
				}
				var mapPoint = toMapPoint(this.allData[i]);
				if (mapPoint && mapPoint.lng && mapPoint.lat && mapPoint.lng !== '0.0' && mapPoint.lat !== '0.0' && mapPoint.lat != '0' && mapPoint.lng != '0') {
					this.linetoMapData[i] = this.allData[i];
				}
			}
			//查询连续性为空的经纬度数据结束空的位置
			this.passageData = [];
			//优化丢失的数据
			//			lostWeightMark=this.fillLosWeighttArr(lostWeightMark);
			//获取异常信息数据
			var self = this;
			let alertReq = 'deviceId=' + activeDeviceId + '&startTime=' + activeStartTime + '&endTime=' + activeEndTime;
			let logReq = 'deviceId=' + activeDeviceId + '&startDate=' + activeStartTime + '&endDate=' + activeEndTime;
			this.jsonApiService.http2("alertlog/queryAllTypeDeviceShutDownAlarmList.html", alertReq).subscribe(result => {
				this.jsonApiService.http2("log/queryLogByDeviceId.html", logReq).subscribe(data => {
					let alertArr = result.data;
					let logArr = data.data;
					let temResult = [];
					if (alertArr.length > 0) {
						for (var i = 0; i < alertArr.length; i++) {
							alertArr[i].flag = 'alert';
						}
						temResult = temResult.concat(alertArr);
					}
					if (logArr.logForCoeList.length > 0) {

						for (var i = 0; i < logArr.logForCoeList.length; i++) {
							logArr.logForCoeList[i].flag = 'coef';
						}
						temResult = temResult.concat(logArr.logForCoeList);
					}
					if (logArr.UpgradeInfoList.length > 0) {
						for (var i = 0; i < logArr.UpgradeInfoList.length; i++) {
							logArr.UpgradeInfoList[i].flag = 'version';
						}
						temResult = temResult.concat(logArr.UpgradeInfoList);
					}
					//					this.powerOffAlertList = [];
					let len = temResult.length;
					let offlineError = [];
					if (len > 0) {
						for (let i = 0; i < len; i++) {
							let tim;
							let sort = 0;
							let item = temResult[i];
							let topos = toMapPoint({
								lng: item.lng,
								lat: item.lat,
							});
							if (topos) {
								item.lng = topos.lng;
								item.lat = topos.lat;
							};
							if (item.flag == 'alert') {
								tim = this.changeTime(item.offTime);
							} else if (item.flag == 'coef') {
								tim = this.changeTime(item.sendTime);
							} else if (item.flag == 'version') {
								tim = this.changeTime(item.createTime);
							}
							for (let j = sort; j < this.allData.length; j++) {
								let _item = this.allData[j];
								let _tim = this.changeTime(_item.uploadDate);
								if (_tim - tim >= 0 && j > 0) {
									sort = j;
									let errorItem: any;
									if (item.type == 1 && item.flag == 'alert') {
										errorItem = {
											name: '离线警报',
											value: '离',
											xAxis: j - 1,
											yAxis: this.allData[j - 1].weight,
											lostime: '',
											rangeTime: item.totalSecond ? this.convertTime(item.totalSecond) : '离线中',
											symbol: 'image://assets/img/trackImage/ofline_jb.png',
											symbolSize: 24,
											symbolOffset: ['0', '-50%'],
										};
									} else if (item.type == 2 && item.flag == 'alert') {
										errorItem = {
											name: '断电警报',
											value: '',
											xAxis: j - 1,
											yAxis: this.allData[j - 1].weight,
											lostime: '',
											rangeTime: item.totalSecond ? this.convertTime(item.totalSecond) : '断电中',
											symbol: 'image://assets/img/trackImage/powerOff2.png',
											symbolSize: 24,
											symbolOffset: ['0', '-50%'],
										};
										//										this.powerOffAlertList.push(item);//断电警报集合,处理echart显示断电区域使用
									} else if (item.flag == 'coef') {
										errorItem = {
											name: '系数设置',
											value: '系',
											xAxis: j - 1,
											yAxis: this.allData[j - 1].weight,
											lostime: '',
											symbol: 'image://assets/img/version_icon.png',
											symbolSize: 26,
											symbolOffset: ['0', '-50%'],
										};
									} else if (item.flag == 'version') {
										errorItem = {
											name: '固件升级',
											value: '固',
											xAxis: j - 1,
											yAxis: this.allData[j - 1].weight,
											lostime: '',
											symbol: 'image://assets/img/version_icon.png',
											symbolSize: 26,
											symbolOffset: ['0', '-50%'],
										};
									}
									if (errorItem) {
										for (let keys in item) {
											errorItem[keys] = item[keys];
										}
										offlineError.push(errorItem);
									}
									break;
								}
							}
						}
					}
					/**
					 *   处理警报不在历史数据时间范围之内,但在搜索的时间范围.  将不在历史数据时间范围的数据,补打在历史数据最后时间点上.
					 */
					for (let w = 0; w < alertArr.length; w++) {
						let itemAlert = alertArr[w];
						if (this.changeTime(itemAlert.offTime) > this.changeTime(this.allData[this.allData.length - 1].uploadDate)) {
							let errorItem: any;
							let index = alertArr.length - w;
							if (itemAlert.type == 1 && itemAlert.flag == 'alert') {
								errorItem = {
									name: '离线警报',
									value: '离',
									xAxis: this.allData.length - index,
									yAxis: this.allData[this.allData.length - index].weight,
									lostime: '',
									rangeTime: itemAlert.totalSecond ? this.convertTime(itemAlert.totalSecond) : '离线中',
									symbol: 'image://assets/img/trackImage/ofline_jb.png',
									symbolSize: 24,
									symbolOffset: ['0', '-50%'],
								};
							} else if (itemAlert.type == 2 && itemAlert.flag == 'alert') {
								errorItem = {
									name: '断电警报',
									value: '',
									xAxis: this.allData.length - index,
									yAxis: this.allData[this.allData.length - index].weight,
									lostime: '',
									rangeTime: itemAlert.totalSecond ? this.convertTime(itemAlert.totalSecond) : '断电中',
									symbol: 'image://assets/img/trackImage/powerOff2.png',
									symbolSize: 24,
									symbolOffset: ['0', '-50%'],
								};
							}
							if (errorItem) {
								for (let keys in itemAlert) {
									errorItem[keys] = itemAlert[keys];
								}
								offlineError.push(errorItem);
							}
						}
					}
					for (let i = 0; i < offlineError.length; i++) {
						let item = offlineError[i];
						let isFind = false;
						for (let _i = 0; _i < lostWeightMark.length; _i++) {
							let iem = lostWeightMark[_i];
							if (iem.flag) {
								if (item.xAxis == iem.xAxis) {
									item.xAxis = item.xAxis + 1;
									item.lostime = iem.lostime;
									lostWeightMark.push(item);
									isFind = true;
									break;
								}
							} else {
								if ((item.xAxis < iem.xAxis + 1 && item.xAxis > iem.xAxis - 1) || (item.xAxis == iem.xAxis)) {
									item.lostime = iem.lostime;
									lostWeightMark[_i] = item;
									isFind = true;
									break;
								}
							}
						}
						if (!isFind) lostWeightMark.push(item);
					}
					this.passageData.push({
						name: '重量（吨）',
						type: 'line',
						borderWidth: 5,
						itemStyle: {
							color: '#c23531',
						},
						data: this.weightArr,
						markArea: {
							itemStyle: {
								color: '#ddd',
								opacity: 0.5,
							},
							label: {
								color: '#333',
								fontSize: "16",
								position: ['50%', '50%'],
								offset: [-24, -8]
							},
							emphasis: {
								itemStyle: {
									color: '#ddd',
									opacity: 0.5,
								},
								label: {
									position: ['50%', '50%'],
									offset: [-24, -8]
								}
							},
							data: this.timeShadow,
						},
						markPoint: {
							data: lostWeightMark,
							itemStyle: {
								normal: {
									label: {
										fontSize: 10
									}
								}
							}
						}
					})

					if (isLostGps) {
						this.passageData.push({
							name: '',
							type: 'line',
							itemStyle: {
								color: 'gray'
							},
							lineStyle: {
								width: 3, //折线宽度
							},
							data: nullGpsArr,
							markPoint: {
								data: nullMarkerData
							}
						})
					}
					//时间轴
					this.echartOption.xAxis.data = timeValue;
					//ad信号
					this.showAdSignal();
					if (this.carSpeed) {
						this.yAxiSpeed.min = 0;
						this.yAxiSpeed.max = 120;
						this.showCarSpeed();
					}
					if (this.loadometer) {
						this.showLoadometer()
					}
					this.yAxiSignal.show = this.lookSignal;
					this.yAxiSpeed.show = this.carSpeed;
					this.echartOption.yAxis = [this.yAxiWeight, this.yAxiSignal, this.yAxiSpeed];
					this.echartOption.series = this.passageData;
					this.legendSleced['手刹信号'] = false;
					this.echartOption.legend.selected = this.legendSleced;
					//this.myChart.setOption(this.echartOption, true);
					//this.showMapTrack();
					this.jsonApiService.http2("realtime/getRealTimeDataForBase.html", 'deviceId=' + activeDeviceId).subscribe(result => {
						if (result.data.unit == '2') {
							this.echartOption.series[0].name = '重量（千克）';
						}
						this.myChart.setOption(this.echartOption, true);
						this.showMapTrack();
						this.voltageChange();
					})
				})
			})
		})
	}

	fillLosWeighttArr(paramArr) {
		let result = [];
		let len = paramArr.length;
		if (len > 30) {
			let eq = Math.floor(this.allData.length / 100);
			let multiple = 1.5;//倍数
			for (let i = 0; i < len - 1; i++) {
				let item1 = paramArr[i];
				let item2 = paramArr[i + 1];
				if (i < 1) {
					result.push(item1);
				} else {
					let sort = item2.xAxis - item1.xAxis;
					if (sort > eq || item2.lostime > item1.lostime * multiple || item2.lostime < item1.lostime / multiple) {
						result.push(item1);
					}
				}
			}
			if (len > 1) {
				let lastItem = paramArr[len - 1];
				result.push(lastItem);
			}
		}
		else {
			result = paramArr;
		}
		return result;
	}

	//绘画车辆速度折线
	showCarSpeed() {
		let obj = {
			name: '车辆速度',
			type: 'line',
			yAxisIndex: 2,
			itemStyle: {
				normal: {
					color: '#5793f3',
					lineStyle: {
						width: 1, //折线宽度
						opacity: 0.5,
					}
				}
			},
			data: this.carSpeedArr,
			areaStyle: {
				color: 'rgba(83, 146, 230,0.5)'
			}
		};
		this.passageData.push(obj);
	}
	//绘画ad信号折线,及丢失数据点.
	showAdSignal() {
		this.passageName = [];
		this.passageArr = [];
		var data = this.allData
		var len = data.length;
		let wareStatusArr = [];//手刹信号
		//nullPassArr中对应的值为空的时候,从allPassArr移除对应的通道数据,最终得到filterArr过滤后的数据this.passageArr
		var allPassArr = [];//16通道所有的数组        
		var nullPassArr = [];//记录通道全部数据是否为空.,默认值为true
		for (var z = 0; z < 16; z++) {
			var newArr = new Array();
			allPassArr.push(newArr);
			nullPassArr.push(true);
		}
		for (var i = 0; i < len; i++) {
			var handSingal = parseFloat(data[i].handBrakeHardwareStatus) * 10 * this.multiple;//手刹信号放大10万倍
			if (handSingal >= 0 || handSingal < 0) {
				wareStatusArr[i] = handSingal;
			}
			for (var j = 0; j < 16; j++) {
				var name = 'aCH' + (j + 1);
				var passVal = parseFloat(data[i][name]);//获取16个通道的值;
				allPassArr[j][i] = passVal;
				if (passVal > 0 || passVal < 0) {
					nullPassArr[j] = false;
				}
			}
		}

		this.legendSleced = {};
		for (var _z = 0; _z < nullPassArr.length; _z++) {
			if (!nullPassArr[_z]) {
				var passName = '通道' + (_z + 1);
				this.passageName.push(passName);
				this.passageArr.push(allPassArr[_z]);

				if (this.hideOrshowline.indexOf(passName) > -1) {
					this.legendSleced[passName] = true;
				} else {
					this.legendSleced[passName] = false;
				}

			}
		}
		if (!nullPassArr[15]) {
			// 当16通道的值不为空时候
			this.signal16Arr = allPassArr[15];
			this.isRate16 = true;
		}
		else {
			this.isRate16 = false;
		}
		if (wareStatusArr.length > 1) {
			this.passageName.push('手刹信号');
			this.passageArr.push(wareStatusArr);
		}

		if (this.lookSignal) {

			for (var _i = 0; _i < this.passageName.length; _i++) {
				var obj = {
					name: this.passageName[_i],
					type: 'line',
					yAxisIndex: 1,
					itemStyle: {
						color: common.lineGetColor(_i)
					},
					lineStyle: {
						width: 2, //折线宽度
						opacity: 0.75
					},
					data: this.passageArr[_i]
				};
				if (this.passageName[_i] === '手刹信号') {
					obj.itemStyle = {
						color: '#8B668B'
					};
					obj.yAxisIndex = 0;
				}
				this.passageData.push(obj);
			}
		}
	}

	//地图联动绘画轨迹路线.
	showMapTrack() {
		let pointArr = this.linetoMapData;
		let map = this.myMap;
		//绘制路线

		var geturl = config.BaseURL;
		let lineStyle = { star: true, end: false, color: true, infoUrl: geturl };
		drawTrackLine(pointArr, map, lineStyle);
		if (pointArr.length != 0) {
			setTimeout(function () {
				map.centerAndZoom(new BMap.Point(pointArr[pointArr.length - 1].lng, pointArr[pointArr.length - 1].lat), 12);
			}, 10);
		}
		let that = this;
		let promptBox = $('.weightPromptBox');
		let alertPromptBox = $('.alertPromptBox');
		let versionChartModuleBox = $('.versionChartModuleBox');
		let coefChartModuleBox = $('.coefChartModuleBox');
		this.myChart.on('mouseout', function (params) {
			promptBox.hide();
			alertPromptBox.hide();
			versionChartModuleBox.hide();
			coefChartModuleBox.hide();
		})
		var options = {
			size: 7,
			shape: 3,
			color: 'rgba(0, 0, 0, 0)'
		};
		this.myChart.on('mousemove', function (params, event) {
			if (that.isMoveFlag) {
				that.isMoveFlag = false;
				if (params.seriesType === 'scatter') {
					// 点击地磅数据的点
					var e = event || window.event;
					var x1 = $('#content').offset().left;
					var y1 = $('#content').offset().top;
					var x = e.clientX - x1 - 20 - promptBox.width();
					var y = e.clientY - y1 - 20 - promptBox.height();
					that.poundWeight = params.data;//当前地磅重量
					that.errorValue = common.twoDecimal(that.allData[params.dataIndex].weight * that.multiple - params.data);//重量误差值
					if (params.data == 0) {
						that.errorRate = '';
					}
					else {
						that.errorRate = common.twoDecimal(Math.abs(that.errorValue / params.data) * 100);//重量误差率 
					}
					if (that.isRate16) {
						that.ad16Value = common.twoDecimal(that.signal16Arr[params.dataIndex] * that.multiple - params.data);//16通道信号误差值
						if (that.ad16Value == 0) {
							that.ad16Rate = 0;
						}
						else {
							if (params.data == 0) {
								that.ad16Rate = '';
							}
							else {
								that.ad16Rate = common.twoDecimal(Math.abs(that.ad16Value / params.data) * 100);//16通道信号误差率
							}
						}
					}
					promptBox.show().animate({ left: x + 'px', top: y + 'px' }, 10);
				}
				else {
					promptBox.hide();
				}
				if (params.componentType === 'markPoint') {
					if (params.name == "离线警报" || params.name == "断电警报") {
						params.data.onTime = params.data.onTime ? params.data.onTime : '无';
						that.alertChartModelInfo = params.data;
						var e = event || window.event;
						var x = e.offsetX - 272;
						var y = (e.offsetY - 32) > 260 ? e.offsetY - 32 : e.offsetY - 120;
						alertPromptBox.show().animate({ left: x + 'px', top: y + 'px' }, 10);
					}
					if (params.name == "固件升级") {
						that.versionChartModuleInfo = params.data;
						var e = event || window.event;
						var x = e.offsetX - 384;
						var y = (e.offsetY - 32) > 260 ? e.offsetY - 32 : e.offsetY - 80;
						versionChartModuleBox.show().animate({ left: x + 'px', top: y + 'px' }, 10);
					}

					if (params.name == "系数设置") {
						that.coefChartModuleInfo = params.data;
						var e = event || window.event;
						var x = e.offsetX - 324;
						var y = (e.offsetY - 32) > 260 ? e.offsetY - 32 : e.offsetY - 80;
						coefChartModuleBox.show().animate({ left: x + 'px', top: y + 'px' }, 10);
					}
				}
				that.myMap.closeInfoWindow(); //关闭信息窗口
				setTimeout(() => {
					that.isMoveFlag = true;
				}, 80);
			}
		})
	}
	//折线移动,地图轨迹添加坐标位置点函数
	lineMoveCarPoint(data) {
		if (data.lat > 0) {
			var mp = this.myMap;
			var update = function update() {
				var ctx = this.canvas.getContext("2d");
				if (!ctx) {
					return;
				}
				ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
				var point = new BMap.Point(data.lng, data.lat);
				var pixel = mp.pointToPixel(point);
				ctx.beginPath();
				ctx.strokeStyle = '#d0d4d7';
				ctx.arc(pixel.x, pixel.y, 35, 0, 2 * Math.PI);
				ctx.stroke();
				ctx.beginPath();
				ctx.fillStyle = 'rgba(35, 152, 255, 0.14)';
				ctx.arc(pixel.x, pixel.y, 34, 0, 2 * Math.PI);
				ctx.fill();
				ctx.beginPath();
				ctx.strokeStyle = '#c2c2c4';
				ctx.arc(pixel.x, pixel.y, 8, 0, 2 * Math.PI);
				ctx.stroke();
				ctx.beginPath();
				ctx.fillStyle = '#fff';
				ctx.arc(pixel.x, pixel.y, 7, 0, 2 * Math.PI);
				ctx.fill();
				ctx.beginPath();
				ctx.fillStyle = '#1496ff';
				ctx.arc(pixel.x, pixel.y, 2.6, 0, 2 * Math.PI);
				ctx.fill();
			};
			if (typeof this.carMoveCanvasLayer != 'undefined') {
				this.carMoveCanvasLayer.options.update = update;
				this.carMoveCanvasLayer._draw();
				return;
			}
			this.carMoveCanvasLayer = new CanvasLayer({
				map: this.myMap,
				update: update,
				zIndex: 10
			});

		}
	}
	//地磅数据赋值到对应的折线数据位置上,若数据上有值则往后移
	loadometerVoluation(sort, weight) {
		if (sort + 1 <= this.loadometerArr.length) {
			if (this.loadometerArr[sort + 1] == '-') {
				this.loadometerArr[sort + 1] = weight;
			}
			else {
				this.loadometerVoluation(sort + 1, weight);
			}
		}
	}
	//获取地磅数据在chart图表显示.
	showLoadometer() {
		var orderIndex = 0;
		for (var x = 0; x < this.loadometerData.length; x++) {
			var time1 = common.mmsstoTimestamp(this.loadometerData[x].date);
			for (var i = orderIndex; i < this.allData.length; i++) {
				var time2 = common.mmsstoTimestamp(this.allData[i].uploadDate);
				orderIndex++;
				if (time2 - time1 >= 0) {
					let lmWeight = parseFloat(this.loadometerData[x].weight);
					this.loadometerVoluation(i - 1, lmWeight);
					break;
				}
			}
		}
		if (this.loadometerData.length >= 1) {
			let obj = {
				name: '地磅数据',
				type: 'scatter',
				yAxisIndex: 0,
				itemStyle: {
					color: 'orange'
				},
				data: this.loadometerArr
			};
			this.passageData.push(obj);
		}
	}

	//ad信号选中画信号折线
	signalChange() {
		let len = this.passageArr.length;
		if (len >= 1) {
			if (this.lookSignal) {

				for (var i = 0; i < len; i++) {
					//添加传感器通道数据
					var obj = {
						name: this.passageName[i],
						type: 'line',
						yAxisIndex: 1,
						itemStyle: {
							color: common.lineGetColor(i)
						},
						lineStyle: {
							width: 2, //折线宽度
							opacity: 0.75
						},
						data: this.passageArr[i]
					};
					if (this.passageName[i] === '手刹信号') {
						obj.itemStyle = {
							color: '#8B668B'
						};
						obj.yAxisIndex = 0;
					}
					this.passageData.push(obj);
				}
			} else {
				var _len = this.passageData.length;

				for (var _i = 0; _i < _len; _i++) {

					let findIndex = this.passageName.indexOf(this.passageData[_i].name);
					if (findIndex > -1) {
						this.passageData.splice(_i, 1);
						_len = _len - 1;
						_i = _i - 1;
					}

				}
			}
			this.yAxiSignal.show = this.lookSignal;
			this.yAxiSpeed.show = this.carSpeed;
			this.echartOption.yAxis = [this.yAxiWeight, this.yAxiSignal, this.yAxiSpeed];
			this.echartOption.series = this.passageData;
			this.myChart.setOption(this.echartOption, true);
		}
	}
	//地磅数据选中画折线
	loadometerChange() {
		if (this.allData.length < 2) {
			return;
		}
		if (this.loadometerData.length >= 1) {

			if (this.loadometer) {
				this.showLoadometer();
			} else {
				let len = this.passageData.length;
				for (var i = 0; i < len; i++) {
					if (this.passageData[i].name === '地磅数据') {
						this.passageData.splice(i, 1);
						break;
					}
				}
			}
			this.echartOption.series = this.passageData;
			this.myChart.setOption(this.echartOption, true);
		} else {
			if (this.loadometer) {
				this.message('该时间段没有地磅数据');
			}
		}
	}
	//车辆速度选中画折线
	carSpeedChange() {
		if (this.carSpeedArr.length >= 1) {
			if (this.carSpeed) {
				this.yAxiSpeed.min = 0;
				this.yAxiSpeed.max = 120;
				this.showCarSpeed();
			} else {
				this.yAxiSpeed.min = undefined;
				this.yAxiSpeed.max = undefined;
				let len = this.passageData.length;
				for (var i = 0; i < len; i++) {
					if (this.passageData[i].name === '车辆速度') {
						this.passageData.splice(i, 1);
						break;
					}
				}
			}
			this.yAxiSignal.show = this.lookSignal;
			this.yAxiSpeed.show = this.carSpeed;
			this.echartOption.yAxis = [this.yAxiWeight, this.yAxiSignal, this.yAxiSpeed];
			this.echartOption.series = this.passageData;
			this.myChart.setOption(this.echartOption, true);
		}
	}
	//修正数据选中画折线
	modifyChange() {
		if (this.allData.length < 1) {
			return;
		}
		this.askforData();
	}


	//选中需要输入框获取折线图上的时间,添加endueTime类事件
	inpSelectEvent(val) {
		this.focusInpType = '';
		this.inpSelect = val;
	}
	//转换时间格式
	convertTime(timeInt) {
		var d, h, m, s;
		if (timeInt >= 0) {
			d = Math.floor(timeInt / 60 / 60 / 24);
			h = Math.floor(timeInt / 60 / 60 % 24);
			m = Math.floor(timeInt / 60 % 60);
			s = Math.floor(timeInt % 60);
		}
		if (d < 1) {
			if (h < 1) {
				// 	 return m+'分'+s+'秒';
				return '约' + m + '分';
			} else {
				return h + '小时' + m + '分';
			}
		} else {
			return d + '天' + h + '小时' + m + '分';
		}
	}

	/**
	 * 设备电压信息开关,this.voltage为true显示,false隐藏
	 */
	voltageChange() {
		if (this.voltage) {
			this.dealVoltageData();
		} else {
			let len = this.passageData.length;
			for (var i = 0; i < len; i++) {
				if (this.passageData[i].name === '设备电压 (v)') {
					this.passageData.splice(i, 1);
					break;
				}
			}
		}
		this.echartOption.series = this.passageData;
		this.myChart.setOption(this.echartOption, true);
	}
	/**
	 * 电压采样半小时一个点,对电压数据值进行补点,处理成和历史数据X轴点数对应;
	 * 补点原理:电压两点之前补前面一个点的值,电压最后一个点之后,补最后一个点值;
	 */
	dealVoltageData() {
		this.voltageDataEchart = [];
		var index = 0;
		var volIndex = 0;
		for (var i = 0; i < this.voltageData.length - 1; i++) {
			var temTime1 = common.mmsstoTimestamp(this.voltageData[i].uploadDate);
			var temTime2 = common.mmsstoTimestamp(this.voltageData[i + 1].uploadDate);
			for (var j = index; j < this.allData.length - 1; j++) {
				var temTime3 = common.mmsstoTimestamp(this.allData[j].uploadDate);
				var temTime4 = common.mmsstoTimestamp(this.allData[j + 1].uploadDate);
				index = j;
				volIndex = i;
				if (temTime3 >= temTime1 && temTime2 >= temTime3) {                //两点之间补点
					this.voltageDataEchart.push(this.voltageData[i].voltage);
				} else if (temTime3 < temTime1) {									//电压最后一点在数据范围之外后,该点之前补点,补上一个点
					this.voltageDataEchart.push(this.voltageData[i - 1].voltage)
				} else if (temTime3 > temTime2 && i < this.voltageData.length - 2) {	//最后一个点之前跳出循环
					if (temTime1 >= this.allData[0]) {
						if (temTime4 - temTime3 > temTime2 - temTime1) {//处理电压连续两点差值小于历史数据两点差值
							this.voltageDataEchart.push(this.voltageData[i].voltage);
							break;
						}
					} else {
						break;
					}
				} else {
					this.voltageDataEchart.push(this.voltageData[i].voltage)
				}
			}
		}
		if (this.allData.length - this.voltageDataEchart.length == 1) {  //处理最一点的值
			this.voltageDataEchart.push(this.voltageData[volIndex].voltage);
		}
		if (this.voltageData.length >= 1) {
			let obj = {
				name: '设备电压 (v)',
				type: 'line',
				yAxisIndex: 0,
				show: true,
				data: this.voltageDataEchart,
				itemStyle: {
					color: 'orange'
				}
			};
			this.passageData.push(obj);
		}
	}



	/**
	 *  线路规划模块=========================================================================================================================================
	 */
	htmlParams: any = {
		carNumber: '',
		deviceId: '',
		startTime: '',
		endTime: '',
		runTime: '',
		runBefore: '',
		stopTime: '',
		stopBefore: '',
		isMakeup: false,
		isRemove: false,
		isAutoApproach: true,
		replaceDeviceId: '',
		replaceCarNumber: '',
		replaceStartTime: '',
		replaceEndTime: '',
		replaceWeight: '',
		replacePath: ''
	}
	planningMarker: any = {
		starPoint: {
			val: '',
			marker: undefined,
		},
		endPoint: {
			val: '',
			marker: undefined,
		},
		approachList: []
	}
	focusInpType: any = '';//区分点击起点,重点,经过点的输入框
	drawTrackDatas = [];//画轨迹的数据
	samplingPoint = {     //抽取途径时用的数据,轨迹数据开始截取sIndex ,截取结束eIndex;runList过滤画轨迹的数据数据中静止的点 listArr最终抽取的途径点
		sIndex: 0,
		eIndex: 0,
		runList: [],
		listArr: []
	}
	startMarker: any;
	endMarker: any; //点击查看轨迹时的轨迹路线,起点，终点
	truckDriving;//轨迹规划实列对象
	planningTrack;//轨迹规划路线
	approachArr = [];//途径点list
	planningPoints = [];//轨迹规划路线的所有经纬度点
	//  singIndex:any;//当前操作的第几个途径点的
	planningsignMarkers = {  //记录轨迹规划时添加的起始,途径点的标记marker
		sMarker: undefined,
		eMarker: undefined,
		approach: [],
	}
	getSelectTime(time) {
		console.log(time, 'time==========')
		this.startTime = time.startTime;
		this.endTime = time.endTime;
		this.htmlParams.startTime = time.startTime;
		this.htmlParams.endTime = time.endTime;
	}
	getFocusInpType(type) {
		this.focusInpType = type;
		this.inpSelect = '';
	}

	//监听开始坐标和结束坐标值的变换   黄钰琪 2020/10/14
	getPointChange(value, type) {
		let position: any//途径点集合,起始点,结束点       ==>转化百度地图后的坐标
		var Point = value;
		var Lnglat = this.changeBmapPointType(Point);
		position = new BMap.Point(Lnglat.lng, Lnglat.lat);//地图起始坐标
		if (type == 'starPoint') {
			if (this.planningMarker.starPoint.marker) {
				this.myMap.removeOverlay(this.planningMarker.starPoint.marker);
			}
			this.planningMarker.starPoint.marker = new BMap.Marker(position, {
				icon: new BMap.Icon('assets/img/trackImage/start_marker.png', new BMap.Size(44, 32)),
				offset: new BMap.Size(3, -12),
			});
			this.myMap.addOverlay(this.planningMarker.starPoint.marker);// 添加起始点
			this.planningMarker.starPoint.marker.enableDragging();// 可拖动注册
			this.planningMarker.starPoint.marker.addEventListener('dragend', function (e) {
				let wgsPoint = toWGS84(e.point);
				if (wgsPoint) {
					this.planningMarker.starPoint.val = wgsPoint.lng + "," + wgsPoint.lat;
				}
			}.bind(this))
		}

		else if (type == 'endPoint') {
			if (this.planningMarker.endPoint.marker) {
				this.myMap.removeOverlay(this.planningMarker.endPoint.marker);
			}
			this.planningMarker.endPoint.marker = new BMap.Marker(position, {
				icon: new BMap.Icon('assets/img/trackImage/end_marker.png', new BMap.Size(44, 34)),
				offset: new BMap.Size(4, -12),
			});
			this.myMap.addOverlay(this.planningMarker.endPoint.marker);// 添加结束点
			this.planningMarker.endPoint.marker.enableDragging();// 可拖动注册
			this.planningMarker.endPoint.marker.addEventListener('dragend', function (e) {
				let wgsPoint = toWGS84(e.point);
				if (wgsPoint) {
					this.planningMarker.endPoint.val = wgsPoint.lng + "," + wgsPoint.lat;
				}
			}.bind(this))
		}
	}
	//添加途径点
	addApproachPoint() {
		let sortIndex = this.planningMarker.approachList.length > 0 ? +this.planningMarker.approachList[this.planningMarker.approachList.length - 1].itemId + 1 : 1;
		let itemApproach = {
			itemId: sortIndex,
			val: '',
			marker: undefined,
		};
		this.planningMarker.approachList.push(itemApproach);
		this.focusInpType = sortIndex;
	}
	// 起始坐标删除
	delStartPoint() {
		this.planningMarker.starPoint.val = '';
		this.focusInpType = '';
		if (this.planningMarker.starPoint.marker) {
			this.myMap.removeOverlay(this.planningMarker.starPoint.marker);
		}
	}
	// 结束坐标删除
	delEndPoint() {
		this.planningMarker.endPoint.val = '';
		this.focusInpType = '';
		if (this.planningMarker.endPoint.marker) {
			this.myMap.removeOverlay(this.planningMarker.endPoint.marker);
		}
	}
	//删除途径点
	delApproachPoint(approachId) {
		let len = this.planningMarker.approachList.length;
		for (let i = 0; i < len; i++) {
			let item = this.planningMarker.approachList[i];
			if (item.itemId == approachId) {
				if (item.marker) {
					this.myMap.removeOverlay(item.marker);
				}
				this.planningMarker.approachList.splice(i, 1);
				break;
			}
		}

		for (let j = 0; j < this.planningMarker.approachList.length; j++) {

			this.planningMarker.approachList[j].itemId = j + 1
		}

		this.focusInpType = '';
	}
	//清空途径点
	removeApproachPoint() {
		this.focusInpType = '';
		let len = this.planningMarker.approachList.length;
		for (let i = 0; i < len; i++) {
			let item = this.planningMarker.approachList[i];
			if (item.marker) {
				this.myMap.removeOverlay(item.marker);
			}
		}
		this.planningMarker.approachList = [];
		this.closeRoutePlanning();
		//      if(this.planningMarker.starPoint.marker) this.myMap.removeOverlay(this.planningMarker.starPoint.marker);
		//      if(this.planningMarker.endPoint.marker) this.myMap.removeOverlay(this.planningMarker.endPoint.marker);
	}

	//获取抽样数据中的在行使数据,过滤静止的数据
	getSamplingApproach() {
		if (this.samplingPoint.sIndex < 1 && this.samplingPoint.eIndex < 1) {
			this.jsonApiService.message('历史数据太少,不足采样途径点');
			return;
		}
		let len3 = this.planningMarker.approachList.length;
		if (len3 > 0) {
			for (let i = 0; i < len3; i++) {
				let marker = this.planningMarker.approachList[i].marker;
				if (marker) {
					this.myMap.removeOverlay(marker);
				}
			}
		}
		this.planningMarker.approachList = [];
		let _listArr = this.drawTrackDatas.slice(this.samplingPoint.sIndex, this.samplingPoint.eIndex);//根据发车时间-卸货前停止区间截取数据后过滤掉静止的数据
		_listArr = _listArr.filter((data) => { return data.speed > 3 });// 速度小于3的数据过滤掉
		let len5 = _listArr.length;
		let allDistance = 0;
		for (let i = 0; i < len5 - 1; i++) {
			allDistance = allDistance + common.caculationDistance(_listArr[i], _listArr[i + 1]);
		}
		if (allDistance < 2000) {
			this.jsonApiService.message('总路程小于2公里,不进行抽取途经点');
			return;
		}
		let eqdis = Math.floor(allDistance / 9);
		var _distace = 0;//区间距离
		this.planningMarker.approachList = [];
		for (let i = 0; i < len5 - 1; i++) {
			let _itme = _listArr[i];
			_distace = _distace + common.caculationDistance(_itme, _listArr[i + 1]);
			if (_distace >= eqdis) {
				_distace = 0;
				this.addApproachPoint();
				let _lens = this.planningMarker.approachList.length;
				this.planningMarker.approachList[_lens - 1].val = _itme.x + ',' + _itme.y;
				this.planningMarkerAdd(_itme.lng, _itme.lat);
			}
		}
	}

	getStartLnglat() {
		let sLngTime, distance1;
		let len = this.drawTrackDatas.length;
		if (len < 10) {
			return;
		}
		if (this.planningMarker.starPoint.val) {
			let startPonit = {
				lng: this.planningMarker.starPoint.val.split(',')[0],
				lat: this.planningMarker.starPoint.val.split(',')[1],
			}
			for (let w = 0; w < len; w++) {
				let distance2 = common.caculationDistance(startPonit, this.drawTrackDatas[w])
				if (distance1) {
					if (distance1 > distance2) {
						distance1 = distance2;
						sLngTime = this.drawTrackDatas[w].uploadDate;
					}
				} else {
					distance1 = distance2;
					sLngTime = this.drawTrackDatas[w].uploadDate;
				}
			}
		} else {
			sLngTime = this.htmlParams.runTime;//起点坐标的时间
		}
		if (!sLngTime) {
			this.jsonApiService.message('请输入上货结束时间或输入开始坐标');
			return;
		}
		for (let i = 0; i < len; i++) {
			let item = this.drawTrackDatas[i];
			let time1 = new Date(item.uploadDate.replace(/-/g, "/")).getTime();
			let time2 = new Date(sLngTime.replace(/-/g, "/")).getTime();
			if (time1 - time2 >= 0) {
				this.samplingPoint.sIndex = i;
				this.focusInpType = 'starPoint';
				if (!this.planningMarker.starPoint.val) {
					this.planningMarker.starPoint.val = item.x + ',' + item.y;
					this.planningMarkerAdd(item.lng, item.lat);
				}
				break;
			}
		}
	}
	getEndLnglat() {
		let eLngTime, distance1;
		let len = this.drawTrackDatas.length;
		if (len < 10) {
			this.jsonApiService.message('轨迹数据太少,无法获取途径点');
			return;
		}
		if (this.planningMarker.endPoint.val) {
			let endPonit = {
				lng: this.planningMarker.endPoint.val.split(',')[0],
				lat: this.planningMarker.endPoint.val.split(',')[1],
			}
			for (let w = 0; w < len; w++) {
				let distance2 = common.caculationDistance(endPonit, this.drawTrackDatas[w]);
				if (distance1) {
					if (distance1 > distance2) {
						distance1 = distance2;
						eLngTime = this.drawTrackDatas[w].uploadDate;
					}
				} else {
					distance1 = distance2;
					eLngTime = this.drawTrackDatas[w].uploadDate;
				}
			}
		} else {
			eLngTime = this.htmlParams.stopBefore;//终点坐标的时间
		}
		if (!eLngTime) {
			this.jsonApiService.message('请输入卸货开始时间或输入结束坐标');
			return;
		}
		for (let i = 0; i < len; i++) {
			let item = this.drawTrackDatas[i];
			let time1 = new Date(item.uploadDate.replace(/-/g, "/")).getTime();
			let time2 = new Date(eLngTime.replace(/-/g, "/")).getTime();
			if (time1 - time2 >= 0) {
				this.samplingPoint.eIndex = i;
				this.focusInpType = 'endPoint';
				if (!this.planningMarker.endPoint.val && this.planningMarker.starPoint.val) {
					this.planningMarker.endPoint.val = item.x + ',' + item.y;
					this.planningMarkerAdd(item.lng, item.lat);
				}
				if (this.planningMarker.starPoint.val && this.planningMarker.endPoint.val) {
					this.getSamplingApproach();
				}
				break;
			}
		}
	}
	// 数据过滤,去掉速度小于3的点



	// 坐标转化,原始坐标转百度坐标
	changeBmapPointType(str) {
		var result;
		var lnglat = str.split(',');
		if (lnglat.length == 2) {
			var point = toMapPoint({ lng: lnglat[0], lat: lnglat[1] });
			if (point) {
				result = point;
			}
		}
		return result;
	}

	closeRoutePlanning() {
		if (!this.routePlanningPolyline) return;
		if (this.planningMarker.starPoint.marker) this.myMap.addOverlay(this.planningMarker.starPoint.marker);
		if (this.planningMarker.endPoint.marker) this.myMap.addOverlay(this.planningMarker.endPoint.marker);
		for (let item of this.planningMarker.approachList) {
			if (item.marker) {
				this.myMap.addOverlay(item.marker);
				// var label = new BMap.Label(item.itemId, { offset: new BMap.Size(5, 4) });
				// label.setStyle({
				// 	color: "red",
				// 	backgroundColor: "0.05",
				// 	border: "0",
				// 	fontSize: '12px',
				// 	fontWeight: "bold",
				// })
				// item.marker.setLabel(label);//给marker添加文本标注
			}

		}
		this.myMap.removeOverlay(this.routePlanningPolyline)
		this.routePlanningPolyline = null
		// this.truckDriving.clearResults();
	}

	getBDPointArray(pathStr) {
		const bdPointArray = []
		const pointStrArr = pathStr.split(';')
		for (let pointStr of pointStrArr) {
			const point = pointStr.split(',')
			const obj = {
				lng: point[0],
				lat: point[1]
			}
			bdPointArray.push(new BMap.Point(obj.lng, obj.lat))
			this.planningPoints.push(toWGS84(obj));
		}
		return bdPointArray
	}

	fetchRoutePlanning(start, end, midPointList) {
		// const origin = '22.673186,114.065699'  //起始点坐标
		// const destination= '22.6721,114.068886' //终点坐标
		// const waypoints //途径点 
		// const requestData = {
		// 	origin: start,
		// 	destination: end,
		// 	waypoints: ''
		// }
		let reqdata = `origin=${start}&destination=${end}`
		if (midPointList.length > 0) {
			// console.log(midPointList.join('|'))
			reqdata += `&waypoints=${midPointList.join('|')}`
			// requestData.waypoints = midPointList.join('|')
		}

		this.jsonApiService.http('trackV3/directionRoute.html', reqdata).subscribe((data) => {
			if (data.success) {
				const bdPointArray = this.getBDPointArray(data.data)
				// console.log(bdPointArray)
				this.routePlanningPolyline = new BMap.Polyline(bdPointArray, {
					strokeColor: "#38ab38",
					strokeWeight: 6,
					strokeOpacity: 0.8
				});
				this.myMap.addOverlay(this.routePlanningPolyline)
				this.myMap.setViewport(bdPointArray)
			} else {
				this.jsonApiService.message(data.message);
			}
		});
	}

	routePlanning() {
		$('.warpBox')[0].style.border = "1px solid #cccccc"; //改变时间区间框的颜色
		let midPointList: any = [], startPonit: any, endPoint: any;//途径点集合,起始点,结束点       ==>转化百度地图后的坐标
		var sMarPoint = this.planningMarker.starPoint.val;
		var eMarPoint = this.planningMarker.endPoint.val;
		if (!eMarPoint || !eMarPoint) {
			this.jsonApiService.message('起始结束坐标不能为空');
			return;
		}
		var sLnglat = this.changeBmapPointType(sMarPoint);
		var eLnglat = this.changeBmapPointType(eMarPoint);
		if (!sLnglat || !eLnglat) {
			this.jsonApiService.message('起始结束坐标转换失败');
			return;
		}
		startPonit = new BMap.Point(sLnglat.lng, sLnglat.lat);//地图起始坐标
		endPoint = new BMap.Point(eLnglat.lng, eLnglat.lat);//地图结束坐标
		// if (this.planningMarker.starPoint.marker) {
		// 	this.myMap.removeOverlay(this.planningMarker.starPoint.marker);
		// }
		// if (this.planningMarker.endPoint.marker) {
		// 	this.myMap.removeOverlay(this.planningMarker.endPoint.marker);
		// }
		let len = this.planningMarker.approachList.length;
		if (len > 0) {
			for (let i = 0; i < len; i++) {
				// let marker = this.planningMarker.approachList[i].marker;
				// if (marker) { this.myMap.removeOverlay(marker); }
				let val = this.planningMarker.approachList[i].val;//每一个途径点的经纬度坐标;
				let transPoint = this.changeBmapPointType(val);
				// if (transPoint) midPointList.push(new BMap.Point(transPoint.lng, transPoint.lat));//途径点
				if (transPoint) midPointList.push(transPoint.lat + ',' + transPoint.lng)
			}
		}
		// var that = this;
		this.planningPoints = [];
		if (this.planningTrack) this.myMap.removeOverlay(this.planningTrack);
		const start = sLnglat.lat + ',' + sLnglat.lng
		const end = eLnglat.lat + ',' + eLnglat.lng
		if (this.routePlanningPolyline) {
			this.myMap.removeOverlay(this.routePlanningPolyline)
			this.routePlanningPolyline = null
		}
		this.fetchRoutePlanning(start, end, midPointList)
		// if (!this.truckDriving) {
		// 	this.truckDriving = new BMap.DrivingRoute(this.myMap, {
		// 		renderOptions: {
		// 			map: this.myMap,
		// 			autoViewport: true,
		// 		},
		// 		onPolylinesSet: function (Route) {
		// 			for (var i = 0; i < Route.length; i++) {
		// 				var polyline = Route[i].getPolyline(); //获取线条遮挡物
		// 				polyline.setStrokeColor("#38ab38"); //设置颜色 
		// 				polyline.setStrokeWeight(6); //设置宽度
		// 				polyline.setStrokeOpacity(0.8); //设置透明度
		// 			}
		// 		},
		// 		onSearchComplete: function (result) {
		// 			// 获取第一条方案
		// 			var plan = result.getPlan(0);
		// 			// 获取方案的驾车线路
		// 			let routelines = plan.getNumRoutes()
		// 			for (let i = 0; i < routelines; i++) {
		// 				var route = plan.getRoute(i);
		// 				let PolylineOptions = route.getPolyline();
		// 				// 获取路线经纬度
		// 				let path = route.getPath();
		// 				for (var j = 0; j < path.length; j++) {
		// 					let obj = {
		// 						lng: path[j].lng,
		// 						lat: path[j].lat
		// 					}
		// 					let toWGS84Point = toWGS84(obj);
		// 					that.planningPoints.push(toWGS84Point);
		// 				}
		// 			}
		// 		}
		// 	})
		// }
		// this.truckDriving.search(startPonit, endPoint, { waypoints: midPointList });
	}
	//地图拾取经纬度点(marker)
	planningMarkerAdd(lng, lat) {
		//      let markerType = $('.getMapPoint').attr('name');
		let position = new BMap.Point(lng, lat);
		// 起始点marker
		if (this.focusInpType == 'starPoint') {
			if (this.planningMarker.starPoint.marker) {
				this.myMap.removeOverlay(this.planningMarker.starPoint.marker);
			}
			this.planningMarker.starPoint.marker = new BMap.Marker(position, {
				icon: new BMap.Icon('assets/img/trackImage/start_marker.png', new BMap.Size(44, 32)),
				offset: new BMap.Size(3, -12),
			});
			this.myMap.addOverlay(this.planningMarker.starPoint.marker);// 添加起始点
			this.planningMarker.starPoint.marker.enableDragging();// 可拖动注册
			this.planningMarker.starPoint.marker.addEventListener('dragend', function (e) {
				let wgsPoint = toWGS84(e.point);
				if (wgsPoint) {
					this.planningMarker.starPoint.val = wgsPoint.lng + "," + wgsPoint.lat;
				}
			}.bind(this))
		}
		// 结束点marker
		else if (this.focusInpType == 'endPoint') {
			if (this.planningMarker.endPoint.marker) {
				this.myMap.removeOverlay(this.planningMarker.endPoint.marker);
			}
			this.planningMarker.endPoint.marker = new BMap.Marker(position, {
				icon: new BMap.Icon('assets/img/trackImage/end_marker.png', new BMap.Size(44, 34)),
				offset: new BMap.Size(4, -12),
			});
			this.myMap.addOverlay(this.planningMarker.endPoint.marker);// 添加结束点
			this.planningMarker.endPoint.marker.enableDragging();// 可拖动注册
			this.planningMarker.endPoint.marker.addEventListener('dragend', function (e) {
				let wgsPoint = toWGS84(e.point);
				if (wgsPoint) {
					this.planningMarker.endPoint.val = wgsPoint.lng + "," + wgsPoint.lat;
				}
			}.bind(this))
		}
		// 途径点marker
		else {
			let len = this.planningMarker.approachList.length;
			for (let i = 0; i < len; i++) {
				let item = this.planningMarker.approachList[i];
				if (this.focusInpType == item.itemId) {
					if (item.marker) {
						this.myMap.removeOverlay(item.marker);
					}
					item.marker = new BMap.Marker(position, {
						icon: new BMap.Icon('assets/img/trackImage/way-point.png', new BMap.Size(42, 38)),
						offset: new BMap.Size(4, -16),
					});
					item.marker.enableDragging();// 可拖动注册
					item.marker.addEventListener('dragend', function (e) {
						var wgsPoint = toWGS84(e.point);
						if (wgsPoint) {
							item.val = wgsPoint.lng + "," + wgsPoint.lat;
							this.focusInpType = item.itemId;
						}
					}.bind(this))
					this.myMap.addOverlay(item.marker);
					var label = new BMap.Label(this.focusInpType, { offset: new BMap.Size(29, 0) });
					label.setStyle({
						color: "#fff",
						backgroundColor: "0.05",
						border: "0",
						fontSize: '6px',
						fontWeight: 'lighter',
						transform: 'scale(0.8)',
					})
					item.marker.setLabel(label);//给marker添加文本标注
					break;
				}
			}
		}
	}

	//地图点击获取起始点坐标位置
	getPointEvent() {
		var that = this;
		this.myMap.addEventListener("click", function (e) {
			if (!that.focusInpType) return;
			that.planningMarkerAdd(e.point.lng, e.point.lat);
			var wgsPoint = toWGS84(e.point);
			if (wgsPoint) {
				let pointString = wgsPoint.lng + "," + wgsPoint.lat;
				if (that.focusInpType == 'starPoint') {
					that.planningMarker.starPoint.val = pointString;
				}
				else if (that.focusInpType == 'endPoint') {
					that.planningMarker.endPoint.val = pointString;
				}
				else {
					let len = that.planningMarker.approachList.length;
					for (let i = 0; i < len; i++) {
						let item = that.planningMarker.approachList[i];
						if (that.focusInpType == item.itemId) {
							item.val = pointString;
						}
					}
				}
			}
		});
	}
	/**
		 * @param deviceId 设备ID
		 * @param startLng 精度-发车点
		 * @param startLat 维度-发车点
		 * @param endLng 精度-卸货点
		 * @param endLat 维度-卸货点
		 * @param runBefore 上货开始时间
		 * @param runTime 上货结束时间
		 * @param stopBefore 卸货开始时间
		 * @param stopTime 卸货结束时间
		 * @param isMakeup 是否填补缺失时间的数据
		 * @param pointArr 坐标集合Json字符串
		 * @param type 修复类型 1曲线修复 2替换修复
		 * @param replaceDeviceId 替换车设备id
		 * @param replaceStartTime 修复车开始时间
		 * @param replaceEndTime 修复车结束时间 
	 */
	//点击修复轨迹获取所选参数
	postData: any = {};
	checkPathFix3: any; //存储的审核数据
	RodioTrack(modal) {
		if (common.getCookie('checkPathFix3')) {
			this.checkPathFix3 = JSON.parse(common.getCookie('checkPathFix3'));
			this.Examine.source = this.checkPathFix3.source;
			this.Examine.reason = this.checkPathFix3.reason
		}

		let timeType1 = common.checkDateFormat(this.htmlParams.runBefore);
		let timeType2 = common.checkDateFormat(this.htmlParams.runTime);
		let timeType3 = common.checkDateFormat(this.htmlParams.stopBefore);
		let timeType4 = common.checkDateFormat(this.htmlParams.stopTime);
		if (this.pathFixType == '1_1') {
			if (!timeType1 || !timeType3) {
				this.jsonApiService.message('请检查输入的时间格式是否正确');
				return;
			}

			//判断时间是否在这个时间区间里面
			if (!this.isDuringDate(this.htmlParams.runBefore, this.startTime, this.endTime)) {
				this.message('查询的时间区间不包含该上货结束时间');
				$('.warpBox')[0].style.border = "1px solid red";
				return;
			}
			if (!this.isDuringDate(this.htmlParams.stopBefore, this.startTime, this.endTime)) {
				this.message('查询的时间区间不包含该卸货开始时间');
				$('.warpBox')[0].style.border = "1px solid red";
				return;
			}

		} else {
			if (!timeType2 || !timeType3) {
				this.jsonApiService.message('请检查输入的时间格式是否正确');
				return;
			}
		}
		var that = this;
		if (that.pathFixType == '1_1' || that.pathFixType == '1_2') {
			that.postData = {
				deviceId: this.deviceId,
				runBefore: this.pathFixType == '1_1' ? '' : this.htmlParams.runBefore,
				runTime: this.pathFixType == '1_1' ? this.htmlParams.runBefore : this.htmlParams.runTime,
				stopBefore: this.htmlParams.stopBefore,
				stopTime: this.htmlParams.stopTime,
				isRemove: this.htmlParams.isRemove,
				isMakeup: this.htmlParams.isMakeup,
				startLng: '',
				startLat: '',
				endLng: '',
				endLat: '',
				pointArr: '',
				type: '1',
				source: this.Examine.source, //问题来源 1客户投诉 2平台发现
				handleReason: this.Examine.reason, //处理原因
				orderId: this.orderId,  //订单id
				orderCode: this.orderCode,
				startTime: this.startTime,  //整个修复区间选择的开始时间
				endTime: this.endTime,  //整个修复区间选择的结束时间
			};
			if (this.planningMarker.starPoint.val) {
				that.postData.startLng = this.planningMarker.starPoint.val.split(',')[0];
				that.postData.startLat = this.planningMarker.starPoint.val.split(',')[1];
				if (!that.postData.startLng || !that.postData.startLat) {
					this.jsonApiService.message('请检查坐标格式是否正确');
					return;
				}
			}
			if (this.planningMarker.endPoint.val) {
				that.postData.endLng = this.planningMarker.endPoint.val.split(',')[0];
				that.postData.endLat = this.planningMarker.endPoint.val.split(',')[1];
				if (!that.postData.endLng || !that.postData.endLat) {
					this.jsonApiService.message('请检查坐标格式是否正确');
					return;
				}
			}
			if (this.planningPoints.length < 2) {
				this.jsonApiService.message('请进行路线规划');
				return;
			}

			//判断时间是否在这个时间区间里面
			if (!this.isDuringDate(this.htmlParams.runBefore, this.startTime, this.endTime)) {
				this.message('查询的时间区间不包含该上货开始时间');
				$('.warpBox')[0].style.border = "1px solid red";
				return;
			}
			if (!this.isDuringDate(this.htmlParams.runTime, this.startTime, this.endTime)) {
				this.message('查询的时间区间不包含该上货结束时间');
				$('.warpBox')[0].style.border = "1px solid red";
				return;
			}
			if (!this.isDuringDate(this.htmlParams.stopBefore, this.startTime, this.endTime)) {
				this.message('查询的时间区间不包含该卸货开始时间');
				$('.warpBox')[0].style.border = "1px solid red";
				return;
			}
			if (!this.isDuringDate(this.htmlParams.stopTime, this.startTime, this.endTime)) {
				this.message('查询的时间区间不包含该卸货结束时间');
				$('.warpBox')[0].style.border = "1px solid red";
				return;
			}

			that.postData.pointArr = JSON.stringify(this.planningPoints);
			// for(let item of this.planningPoints) {

			//     var marker = new BMap.Marker(new BMap.Point(item.lng, item.lat));

			//     this.myMap.addOverlay(marker);  
			// }
		} else if (this.pathFixType == '2') {
			that.postData = {
				deviceId: this.deviceId,
				runBefore: this.htmlParams.runBefore,
				runTime: this.htmlParams.runTime,
				stopBefore: this.htmlParams.stopBefore,
				stopTime: this.htmlParams.stopTime,
				isRemove: this.htmlParams.isRemove,
				isMakeup: this.htmlParams.isMakeup,
				replaceDeviceId: this.htmlParams.replaceDeviceId,
				replaceStartTime: this.htmlParams.replaceStartTime,
				replaceEndTime: this.htmlParams.replaceEndTime,
				type: '2',
				source: this.Examine.source, //问题来源 1客户投诉 2平台发现
				handleReason: this.Examine.reason, //处理原因
				orderId: this.orderId,  //订单id
				orderCode: this.orderCode,
				startTime: this.startTime,  //整个修复区间选择的开始时间
				endTime: this.endTime,  //整个修复区间选择的结束时间
			};
		}

		modal.show();
	}

	//判断是否在时间区间里面
	isDuringDate(newdate, startdate, enddate) {
		var newdateNow = new Date(newdate);
		var startTime = new Date(startdate);
		var endTime = new Date(enddate);
		var a = newdateNow.getTime() - startTime.getTime();
		var b = newdateNow.getTime() - endTime.getTime();
		if (a < 0 || b > 0) {
			return false;
		} else {
			return true;
		}
	}
	getRodioTrack() {
		var that = this
		var postDataObj
		//如果更改了车票号码，则携带过来的orderId 将清除
		if (that.deviceId != that.orderDeviceId) {
			that.orderCode = '';
			that.orderId = ''
		}
		if (that.pathFixType == '1_1' || that.pathFixType == '1_2') {
			postDataObj = {
				deviceId: that.deviceId,
				runBefore: that.pathFixType == '1_1' ? '' : that.htmlParams.runBefore,
				runTime: that.pathFixType == '1_1' ? that.htmlParams.runBefore : that.htmlParams.runTime,
				stopBefore: that.htmlParams.stopBefore,
				stopTime: that.htmlParams.stopTime,
				isRemove: that.htmlParams.isRemove,
				isMakeup: that.htmlParams.isMakeup,
				startLng: that.planningMarker.starPoint.val.split(',')[0],
				startLat: that.planningMarker.starPoint.val.split(',')[1],
				endLng: that.planningMarker.endPoint.val.split(',')[0],
				endLat: that.planningMarker.endPoint.val.split(',')[1],
				pointArr: JSON.stringify(this.planningPoints),
				type: '1',
				source: that.Examine.source, //问题来源 1客户投诉 2平台发现
				handleReason: that.Examine.reason, //处理原因
				orderId: that.orderId,  //订单id
				orderCode: this.orderCode,
				startTime: that.startTime,  //整个修复区间选择的开始时间
				endTime: that.endTime,  //整个修复区间选择的结束时间
			};
		} else if (that.pathFixType == '2') {
			postDataObj = {
				deviceId: that.deviceId,
				runBefore: that.htmlParams.runBefore,
				runTime: that.htmlParams.runTime,
				stopBefore: that.htmlParams.stopBefore,
				stopTime: that.htmlParams.stopTime,
				isRemove: that.htmlParams.isRemove,
				isMakeup: that.htmlParams.isMakeup,
				replaceDeviceId: that.htmlParams.replaceDeviceId,
				replaceStartTime: that.htmlParams.replaceStartTime,
				replaceEndTime: that.htmlParams.replaceEndTime,
				type: '2',
				source: that.Examine.source, //问题来源 1客户投诉 2平台发现
				handleReason: that.Examine.reason, //处理原因
				orderId: that.orderId,  //订单id
				orderCode: this.orderCode,
				startTime: that.startTime,  //整个修复区间选择的开始时间
				endTime: that.endTime,  //整个修复区间选择的结束时间
			};
		}

		this.jsonApiService.http_obj("trackV3/autoretifytrack.html", postDataObj).subscribe(result => {
			this.jsonApiService.message(result.message);
			this.checkPathFix3 = {
				source: this.Examine.source, //问题来源 1客户投诉 2平台发现
				reason: this.Examine.reason, //处理原因
			}
			common.setCookie('checkPathFix3', JSON.stringify(this.checkPathFix3));
		})
	}
	/**点击撤销轨迹获取所选参数*/
	revokeTrack() {
		if (!this.deviceId) {
			this.jsonApiService.message('请输入设备编号');
			return;
		}
		let type = this.pathFixType == '2' ? '2' : '1';
		let reqdata = {
			deviceId: this.deviceId,
			startTime: this.startTime,
			endTime: this.endTime,
			isRemove: this.htmlParams.isRemove,
			type: type,
		}
		//      let reqdata='deviceId='+this.deviceId+'&startTime='+this.startTime+'&endTime='+this.endTime+'&isRemove='+this.htmlParams.isRemove;
		this.jsonApiService.http_obj("track/canceltrack.html", reqdata).subscribe(result => {
			this.jsonApiService.message(result.message);
		})
	}
	isTimeFormat(value) {
		let isTime = common.checkDateFormat(value);
		if (!isTime) {
			this.jsonApiService.message('输入的时间格式不正确,例:2018-08-01 00:00:00');
		}
	}
	pathFixType: string = '1_1';//修复类型,默认曲线修复
	// 曲线修复类型选择
	fixTypeChange(val) {
		this.pathFixType = val;
		// 离线修复时  线路规划以及线路撤销不能点击
		if (val == 2) {
			this.isButtonDis = true
		} else {
			this.isButtonDis = false
		}

		//清空所有的地图上打点
		this.delRunBefore();
		this.delStopBefore();
		this.delRunTime();
		this.delStopTime();

		this.delStartPoint(); //取消坐标点
		this.delEndPoint(); //取消坐标点
		this.removeApproachPoint(); //删除途径点

		this.inpSelect = '';
		this.focusInpType = '';
		this.htmlParams = {
			runTime: '',
			runBefore: '',
			stopTime: '',
			stopBefore: '',
			isMakeup: false,
			isRemove: false,
			isAutoApproach: true,
			replaceDeviceId: '',
			replaceCarNumber: '',
			replaceStartTime: '',
			replaceEndTime: '',
			replaceWeight: '',
			replacePath: ''
		};
		this.planningMarker = {
			starPoint: {
				val: '',
				marker: undefined,
			},
			endPoint: {
				val: '',
				marker: undefined,
			},
			approachList: []
		}

	}
	// 查看数据
	dataDraw() {
		if (!this.htmlParams.replaceDeviceId) {
			this.message('请选择需要查看的车辆');
			return;
		}
		if (!this.htmlParams.replaceStartTime) {
			this.message('开始时间不能为空');
			return;
		}
		if (!this.htmlParams.replaceEndTime) {
			this.message('结束时间不能为空');
			return;
		}
		this.drawActive = '2';
		this.askforData();
	}
	//拉取车辆数据
	initReplaceCarNumberSelect2() {
		var that = this;
		$("#replaceCarNumberSelect2").select2({
			language: "zh-CN",
			placeholder: "请选择",
			allowClear: true,
			minimumInputLength: 2, //最少2个字符，select2才显示查询的内容

			ajax: {
				url: config.BaseURL + "stats/carListByCarNumber.html",
				dataType: 'json',
				delay: 50,
				method: "POST",
				xhrFields: {
					withCredentials: true
				},
				data: function (params) {
					return {
						"carNumber": params.term // search term
					};
				},
				processResults: function (data, params) {
					var options = new Array();
					// 小于10个数量才判断重复
					if (data.data.length <= 10) {
						let arr = []
						let sameCar = []
						// 判断相同的车牌号
						for (let index = 0; index < data.data.length; index++) {
							let car = data.data[index];
							if (arr.indexOf(car.carNumber) != -1) {
								sameCar.push(car.carNumber)
							} else {
								arr.push(car.carNumber);
							}
						}
						$(data.data).each(function (index, car) {
							if (sameCar.indexOf(car.carNumber) != -1) {
								options.push({
									id: car.deviceId,
									text: car.carNumber + "[" + car.parentName + "]"
								})
							} else {
								options.push({
									id: car.deviceId,
									text: car.carNumber
								})
							}
						});
					} else {
						$(data.data).each(function (index, car) {
							options.push({
								id: car.deviceId,
								text: car.carNumber
							})
						});
					}
					return {
						results: options //获取查询后的结果
					};
				},
				cache: true
			},
			templateResult: function (state) {
				if (!state.id) { return state.text; }
				var $state = $('<span><i class="fa fa-car green"></i>&nbsp;&nbsp;' + state.text + '</span>');
				return $state;
			},
		}).on("select2:select", function (e) {
			var data = e.params.data;
			that.htmlParams.replaceDeviceId = data.id;
			if (data.text.indexOf('[') > 0) {
				that.htmlParams.replaceCarNumber = data.text.split('[')[0];
			} else {
				that.htmlParams.replaceCarNumber = data.text;
			}
		});
	}
	//擦除车牌号码所选值
	delReplaceCarNumber() {
		this.htmlParams.replaceDeviceId = '';
		this.htmlParams.replaceCarNumber = '';
		var str = $("<span class='select2-selection__placeholder'>请选择</span>");
		$('#replaceCarNumberSelect2').val("");
		$("#select2-replaceCarNumberSelect2-container").empty();
		$("#select2-replaceCarNumberSelect2-container").attr("title", "");
		$("#select2-replaceCarNumberSelect2-container").prepend(str);
	}
	//初始化时间
	initDate() {
		let that = this;
		return new Promise(function (resolve, error) {
			System.import('assets/js/datepicker/js/bootstrap-datetimepicker.min.js').then(() => {
				System.import('assets/js/datepicker/locales/bootstrap-datetimepicker.zh-CN.js').then(() => {
					$("#replaceStartTime").datetimepicker({ //时间插件
						format: "yyyy-mm-dd hh:ii:ss",
						language: "zh-CN",
						autoclose: true,
					}).on("changeDate", function (e) {
						var date = e.date;
						var time = common.getTimeMmss(date);
						that.htmlParams.replaceStartTime = time
						$("#replaceEndTime").datetimepicker("setStartDate", time);
					});
					$("#replaceEndTime").datetimepicker({ //时间插件
						format: "yyyy-mm-dd hh:ii:ss",
						language: "zh-CN",
						autoclose: true,
					}).on("changeDate", function (e) {
						var date = e.date;
						var time = common.getTimeMmss(date);
						that.htmlParams.replaceEndTime = time;
						$("#replaceStartTime").datetimepicker("setEndDate", time);
					});
					resolve();
				})
			})
		});
	}
	//删除按钮
	delDrawSelect() {
		this.deviceId = '';
		this.carNumber = '';
		this.selectedCompanyId = '';
		this.selectedCompanyName = '';
		var str = $("<span class='select2-selection__placeholder'>请选择</span>");
		$('#carNumberSelect2').val("");
		$("#select2-carNumberSelect2-container").empty();
		$("#select2-carNumberSelect2-container").attr("title", "");
		$("#select2-carNumberSelect2-container").prepend(str);
	}
	delRunBefore() {
		this.htmlParams.runBefore = ''
	}
	delRunTime() {
		this.htmlParams.runTime = ''
	}
	delStopBefore() {
		this.htmlParams.stopBefore = ''
	}
	delStopTime() {
		this.htmlParams.stopTime = ''
	}
	delSuggestId() {
		$("#suggestId").val('');
		$("#searchResultPanel").val('');
		var allOverlay = this.myMap.getOverlays();
		for (var i = 0; i < allOverlay.length; i++) {
			if (allOverlay[i].point && allOverlay[i].point.lat == this.baiPoint.lat && allOverlay[i].point.lng == this.baiPoint.lng) {
				this.myMap.removeOverlay(allOverlay[i]);
			}
		}

	}
	suggestIdChange(value) {
		var allOverlay = this.myMap.getOverlays();
		for (var i = 0; i < allOverlay.length; i++) {
			if (allOverlay[i].point && allOverlay[i].point.lat == this.baiPoint.lat && allOverlay[i].point.lng == this.baiPoint.lng) {
				this.myMap.removeOverlay(allOverlay[i]);
			}
		}
	}
	// 线路规划起始点同步公司地址
	startPointFromCompanyAddress() {
		if (this.deviceId && !this.selectedCompanyId) {
			this.jsonApiService.http_obj("car/getCarInfoByDeviceId.html", { deviceId: this.deviceId }).subscribe(data => {
				if (data.success) {
					let companyId = data.data.companyId;
					this.jsonApiService.http_obj("company/companyInfo.html", { id: companyId }).subscribe(data => {
						if (data.success) {
							this.focusInpType = 'starPoint';
							let pointStart = toMapPoint({ lng: data.data.lng, lat: data.data.lat });
							this.planningMarkerAdd(pointStart.lng, pointStart.lat);
							let pointStartValue = data.data.lng + "," + data.data.lat;
							this.planningMarker.starPoint.val = pointStartValue;
							this.myMap.panTo(new BMap.Point(pointStart.lng, pointStart.lat));
						} else {
							this.jsonApiService.message(data.message);
						}
					})
				}
			})
		}
		if (this.selectedCompanyId) {
			this.jsonApiService.http_obj("company/companyInfo.html", { id: this.selectedCompanyId }).subscribe(data => {
				if (data.success) {
					this.focusInpType = 'starPoint';
					let pointStart = toMapPoint({ lng: data.data.lng, lat: data.data.lat });
					this.planningMarkerAdd(pointStart.lng, pointStart.lat);
					let pointStartValue = data.data.lng + "," + data.data.lat;
					this.planningMarker.starPoint.val = pointStartValue;
					this.myMap.panTo(new BMap.Point(pointStart.lng, pointStart.lat));
				} else {
					this.jsonApiService.message(data.message);
				}
			})
		}
	}


















	//坐标点相互转换
	switchBtnChange(orso, type) {
		//pathFixType == '1_1'   [上货结束]和[卸货开始]相互转换
		if (type == '1') {
			if (orso == 'left') {
				// console.log(this.htmlParams.runBefore,'left,1')
				this.htmlParams.stopBefore = this.htmlParams.runBefore;
			}
			if (orso == 'right') {
				// console.log(this.htmlParams.stopBefore,'right,1')
				this.htmlParams.runBefore = this.htmlParams.stopBefore;
			}
		}

		//pathFixType != '1_1'   [上货开始]和[上货结束]相互转换
		if (type == '2') {
			if (orso == 'left') {
				// console.log(this.htmlParams.runBefore,'left,2')
				this.htmlParams.runTime = this.htmlParams.runBefore;
			}
			if (orso == 'right') {
				// console.log(this.htmlParams.runTime,'right,2')
				this.htmlParams.runBefore = this.htmlParams.runTime;
			}
		}

		//pathFixType != '1_1'   [卸货开始]和[卸货结束]相互转换
		if (type == '3') {
			if (orso == 'left') {
				// console.log(this.htmlParams.stopBefore,'left,3')
				this.htmlParams.stopTime = this.htmlParams.stopBefore;
			}
			if (orso == 'right') {
				// console.log(this.htmlParams.stopTime,'right,3')
				this.htmlParams.stopBefore = this.htmlParams.stopTime;
			}
		}

		//pathFixType == '2'   [开始坐标]和[结束坐标]相互转换
		if (type == '4') {
			if (orso == 'left') {
				// console.log(this.planningMarker.starPoint.val,'left,4')
				this.planningMarker.endPoint.val = this.planningMarker.starPoint.val;
				this.getPointChange(this.planningMarker.starPoint.val, 'endPoint') //地图上打点
			}
			if (orso == 'right') {
				// console.log(this.planningMarker.endPoint.val,'right,4')
				this.planningMarker.starPoint.val = this.planningMarker.endPoint.val;
				this.getPointChange(this.planningMarker.endPoint.val, 'starPoint') //地图上打点
			}
		}


		//pathFixType != '2'   [开始时间]和[结束时间]相互转换
		if (type == '5') {
			if (orso == 'left') {
				// console.log(this.htmlParams.replaceStartTime,'left,5')
				this.htmlParams.replaceEndTime = this.htmlParams.replaceStartTime;
			}
			if (orso == 'right') {
				// console.log(this.htmlParams.replaceEndTime,'right,5')
				this.htmlParams.replaceStartTime = this.htmlParams.replaceEndTime;
			}
		}

	}

	/**
	 * 提交GPS审核
	 */
	Examine: any = {
		source: '1',
		reason: '无GPS'
	}
	sourceList: any = [{
		value: '1',
		text: '客户投诉'
	}, {
		value: '2',
		text: '平台发现'
	}];
	GPSModuleList: any = [
		{
			faultTypeName: 'GPS问题',
			programType: '203',
			text: '无GPS',
			code: 'GP1',
			selected: false,
			isGpsError: '3',
		}, {
			faultTypeName: 'GPS问题',
			programType: '203',
			text: '停车速度平直',
			code: 'GP2',
			selected: false,
			isGpsError: '4',
		}, {
			faultTypeName: 'GPS问题',
			programType: '203',
			text: '大段丢失',
			code: 'GP3',
			selected: false,
			isGpsError: '5',
		}, {
			faultTypeName: 'GPS问题',
			programType: '203',
			text: '偶尔丢失',
			code: 'GP4',
			selected: false,
			isGpsError: '6',
		}, {
			faultTypeName: '主机问题',
			programType: '201',
			text: '离线',
			selected: false,
		}, {
			faultTypeName: '主机问题',
			programType: '201',
			text: '断电跑车',
			selected: false,
		}
	]

	closeGPSExamineModal(modal) {
		modal.hide()
	}

	submitGPSExamineModal(modal) {
		modal.hide();
		this.getRodioTrack();
	}

	sourceChange(value) {
		this.Examine.source = value
	}

	reasonChange(value) {
		this.Examine.reason = value
	}
}
